473,385 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Very slow speed adding Rows to Dataset

I need to insert rows to a database table after processing a piece of an XML file.
The XML file would look something like:

<Book>
<Chapter>
<Page>
<Paragraph>
<Paragraph>
</Page>
</Chapter>
</Book>

The table I am inserting data into is for the paragraph node. If there are 10 Books, with 12 chapters each of which has 30 pages and each page having Paragraph, then I am talking about ~3600 rows.

Below is the pseudo code for how I am doing this: Its very very slow. It takes about 10 mins to insert 3600 rows. I need a faster way. Can someone please help ? (table.NewRow() seems to be taking a lot of time, about 1 min for approx 360 rows.)


Create connection;
Fill dataset ds;

foreach (XmlNode book in Books)
{
XmlNode Chapters = book.SelectNodes("Chapter");

foreach (XmlNode chapter in Chapters)
{
XmlNode Pages = chapter.SelectNodes("Pages");
foreach (XmlNode Page in Pages)
{
XmlNode paras = Page.SelectNodes("Paragraphs");
foreach (XmlNode para in paras)
{
DataTable table = ds.Tables["Para_table"];
DataRow row = table.NewRow();

row[0] = para.Attributes["text"].InnerXml;
row[1] = Page.Attributes["pageno"].InnerXml;
row[2] = chapter.Attributes["chapterno"].InnerXml;
row[3] = book.Attributes["title"].InnerXml;

table.Rows.Add(row);
}
}
}
}
Apr 11 '08 #1
0 1248

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dror | last post by:
Hello, I have a problem that actually doesn't even make sense. I have 4 million rows in my database. I want to get all records into a DataReader and then read. So if I do it in DAO (either in VB...
11
by: DJJ | last post by:
I am using the MySQL ODBC 3.51 driver to link three relatively small MySQL tables to a Microsoft Access 2003 database. I am finding that the data from the MySQL tables takes a hell of a long time...
5
by: krystoffff | last post by:
I currently have PostgreSQL 7.1 installed on a server with about 700 Mb of RAM. I have many problems of speed with a database I created. For example, it took almost 12 sec to run the query...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
29
by: Geoff Jones | last post by:
Hi All I hope you'll forgive me for posting this here (I've also posted to ado site but with no response so far) as I'm urgently after a solution. Can anybody help me? I'm updating a table on...
3
by: michael | last post by:
Hi, I am trying to write an ASP.NET web app, in Visual Basic.NET, using Visual Studio.NET 2004, .NET framework 1.1.4322 SP1 Running the project/app on localhost while in dev/write/debug stage ...
2
by: mavrick_101 | last post by:
Hi, I have a nested repeater. For each row in the parent repeater there is a child repeater with several rows of data. The way I'm doing this is throught ItemDataBound Event. So for each Row...
12
by: MGM | last post by:
Hey everyone, I'm having some issues here. I have a large Access .mdb (over 400,000 rows). What I need to do is, there are 12 columns that need to be reordered (quite literally as simple as if...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.