Click here to Skip to main content
15,914,162 members
Home / Discussions / C#
   

C#

 
AnswerRe: Update Database from DataSet Question Pin
PaulPrice23-Jun-07 2:25
PaulPrice23-Jun-07 2:25 
GeneralRe: Update Database from DataSet Question Pin
Rick van Woudenberg23-Jun-07 2:30
Rick van Woudenberg23-Jun-07 2:30 
GeneralRe: Update Database from DataSet Question Pin
Luc Pattyn23-Jun-07 2:46
sitebuilderLuc Pattyn23-Jun-07 2:46 
GeneralRe: Update Database from DataSet Question Pin
PaulPrice24-Jun-07 21:26
PaulPrice24-Jun-07 21:26 
Questionhow to use Rdlc Report to Run Time Pin
imran_Shaikh23-Jun-07 1:08
imran_Shaikh23-Jun-07 1:08 
QuestionCross development platform form embedding. Pin
daviiie23-Jun-07 0:20
daviiie23-Jun-07 0:20 
AnswerRe: Cross development platform form embedding. Pin
Kevin McFarlane23-Jun-07 0:36
Kevin McFarlane23-Jun-07 0:36 
QuestionDataTable performance issue. Pin
syntaxed22-Jun-07 21:58
syntaxed22-Jun-07 21:58 
Hi,

I needed to add 80,000 records. I do following, see following pseudo:

1. While(Readline != EOF)
2. Create a row
3. Add the Row to the DataTable (this starts slowing down after 30,000 records, and goes completely blank around 80th,000 record)
3. End While
4. Dump the DataTable in to MS Access database.

Although I am using a background worker thread, but all is in vain.

public void RunThd(object theFile)<br />
{<br />
<br />
Thread thd = new Thread(Go);<br />
<br />
thd.IsBackground = true;<br />
<br />
thd.Start(theFile);//Starting the thread, passing the StreamReader as an argument.<br />
<br />
}


Following code is working OK. Reads the StreamReader, prepares Rows, and dumps the DataTable into the MYTABLE1 table.

void Go(object theFile)<br />
<br />
{<br />
<br />
StreamReader Reader = (StreamReader)theFile;<br />
<br />
string sqlSelect = "SELECT * FROM MYTABLE1";<br />
<br />
string sqlConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[@"conString"].ConnectionString;<br />
<br />
try<br />
<br />
{<br />
<br />
DataTable dTable = new DataTable();<br />
<br />
OleDbConnection oleConnection = new OleDbConnection(sqlConnectionString);<br />
<br />
OleDbDataAdapter oleAdapter = new OleDbDataAdapter(sqlSelect, oleConnection);<br />
<br />
OleDbCommandBuilder cmdBuilder = new OleDbCommandBuilder(oleAdapter); //Command Builder<br />
<br />
oleAdapter.Fill(dTable);<br />
<br />
string strLine = stReader.ReadLine();<br />
<br />
//Prepare all of the Rows - around 80,000 records.<br />
<br />
DataRow thisRow = null;<br />
<br />
while (!Reader.EndOfStream)<br />
<br />
{<br />
<br />
strLine = stReader.ReadLine();<br />
<br />
//Add rows<br />
<br />
thisRow = dTable.NewRow();<br />
<br />
 <br />
<br />
thisRow["Col1"] = strLine.Substring(0, 1);<br />
<br />
thisRow["Col2"] = strLine.Substring(1, 11);<br />
<br />
thisRow["Col3"] = strLine.Substring(11, 1);<br />
<br />
dTable.Rows.Add(thisRow);//after around 30000 records, app seems slower.<br />
}<br />
<br />
//Update database<br />
oleAdapter.AcceptChangesDuringFill = true;<br />
oleAdapter.Fill(dTable);<br />
<br />
oleAdapter.Update(dTable);//updates the table in ms access database. Is it possible to refresh DataTable after 10,000 records? Just to mitigate the performance issues? Add 10,000 records, then refresh DataTable, then Add another 10000 and refresh, and so on for the rest of the records.<br />
<br />
}<br />
<br />
catch (Exception e)<br />
{<br />
MessageBox.Show(e.Message);<br />
}<br />
<br />
}<br />
<br />
}


Problem with the code above:

Performance Issues. The app goes down. System starts getting slow, etc. Although, I am using a Background thread, and not using ExecuteNonQuery() that will make app more slower. All that is going good, is really not so well.

Resolution:

Things that I was thinking are:

1. Dump every 10,000 records, and then refresh the DataTable, then fill next 10,000 and dump into the database, and so on so forth. But how to achieve this, needs a Flood Light to be thrown upon (0:

2. Cannot think of any other option?

Thanks for reading all of it. I'd appreciate ideas, helps, comments, suggestions, codes, pointers, etc. Bottomline, need help resolving the performance issue.
AnswerRe: DataTable performance issue. Pin
kubben23-Jun-07 1:55
kubben23-Jun-07 1:55 
GeneralRe: DataTable performance issue. Pin
syntaxed24-Jun-07 18:58
syntaxed24-Jun-07 18:58 
GeneralRe: DataTable performance issue. Pin
kubben25-Jun-07 1:35
kubben25-Jun-07 1:35 
GeneralRe: DataTable performance issue. Pin
syntaxed25-Jun-07 22:06
syntaxed25-Jun-07 22:06 
AnswerRe: DataTable performance issue. Pin
Malcolm Smart23-Jun-07 12:19
Malcolm Smart23-Jun-07 12:19 
GeneralRe: DataTable performance issue. Pin
syntaxed24-Jun-07 19:02
syntaxed24-Jun-07 19:02 
QuestionPopulating the TreeView control from the SQL server in C# .NET application [modified] Pin
thachil22-Jun-07 21:40
thachil22-Jun-07 21:40 
AnswerRe: Populating the TreeView control from the SQL server in C# .NET application Pin
Christian Graus22-Jun-07 21:42
protectorChristian Graus22-Jun-07 21:42 
GeneralRe: Populating the TreeView control from the SQL server in C# .NET application Pin
thachil22-Jun-07 22:11
thachil22-Jun-07 22:11 
GeneralRe: Populating the TreeView control from the SQL server in C# .NET application Pin
sidbaruah25-Jun-07 2:04
sidbaruah25-Jun-07 2:04 
Questionhow to make windows calculator in c#? Pin
seeng22-Jun-07 15:14
seeng22-Jun-07 15:14 
AnswerRe: how to make windows calculator in c#? Pin
Christian Graus22-Jun-07 15:19
protectorChristian Graus22-Jun-07 15:19 
Questionhow to make T9 dictionary in c#? Pin
seeng22-Jun-07 15:09
seeng22-Jun-07 15:09 
AnswerRe: how to make T9 dictionary in c#? Pin
Christian Graus22-Jun-07 15:19
protectorChristian Graus22-Jun-07 15:19 
GeneralRe: how to make T9 dictionary in c#? Pin
Laubi22-Jun-07 21:11
Laubi22-Jun-07 21:11 
AnswerRe: how to make T9 dictionary in c#? Pin
Laubi22-Jun-07 21:10
Laubi22-Jun-07 21:10 
QuestionResource dlls Pin
Christian Graus22-Jun-07 14:01
protectorChristian Graus22-Jun-07 14:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.