PC Review


Reply
Thread Tools Rate Thread

batch updating of a MSSQL table with new rows in a datatable

 
 
Robert Bravery
Guest
Posts: n/a
 
      23rd Jul 2006
HI all,
I have part of my code that looks like this:
foreach (DataRow dtrow in _dtStaging.Rows)
{
DataRow newDatReportRow = _ds.datReportData.NewRow();
newDatReportRow["ReportID"] = 1;
newDatReportRow["MeasureID"] = 5;
newDatReportRow["Value"] = dtrow["Value"];
newDatReportRow["ReportDay"] = 2;
newDatReportRow["ReportMonth"] = 1;
newDatReportRow["ReportYear"] = 2006;
newDatReportRow[2] = dtrow["Profit_Center"];
_ds.datReportData.Rows.Add(newDatReportRow);
ncount++;
}
THis then adds over 15000 rows to the datatables, whats the best way of
doing an update to the sql table.
If call update inside the foreach loop, it seems to take a while, if I do
it outside I get a keyviolation erro

Thanks
Robert


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
updating pivot table to include additional rows =?Utf-8?B?RWxsZW4=?= Microsoft Excel Misc 8 15th Jul 2008 01:33 PM
DataTable, SqlDataAdaptor and updating deleted rows (v1.1) Chris Chilvers Microsoft ADO .NET 0 29th Apr 2006 07:25 AM
Updating multiply rows in a table =?Utf-8?B?Q3VydCBKb2huc29u?= Microsoft Access 1 28th Apr 2006 02:49 PM
Updating datatable using datatable.rows.find() Lars E Microsoft C# .NET 1 27th Apr 2006 09:28 AM
Keeping a series table from updating when adding new rows. =?Utf-8?B?SmFjZW4gU2FyYWNlbg==?= Microsoft Excel Charting 2 18th Jul 2005 04:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:25 PM.