Click here to Skip to main content
15,900,258 members
Home / Discussions / C#
   

C#

 
AnswerRe: Hide from Alt+Tab screen Pin
Ed.Poore15-Feb-07 14:59
Ed.Poore15-Feb-07 14:59 
QuestionGood N-Tier book for Newbie Pin
allan.gagnon15-Feb-07 6:55
allan.gagnon15-Feb-07 6:55 
QuestionA low quality-like gradient Pin
sharpiesharpie15-Feb-07 6:48
sharpiesharpie15-Feb-07 6:48 
AnswerRe: A low quality-like gradient Pin
Insincere Dave15-Feb-07 9:54
Insincere Dave15-Feb-07 9:54 
QuestionDisplay image from SQL DB on to Picturebox In Windows Forms App Pin
bemahesh15-Feb-07 6:15
bemahesh15-Feb-07 6:15 
QuestionBitmap Overlay Advice Pin
BRShroyer15-Feb-07 5:41
BRShroyer15-Feb-07 5:41 
AnswerRe: Bitmap Overlay Advice Pin
Luc Pattyn15-Feb-07 9:45
sitebuilderLuc Pattyn15-Feb-07 9:45 
QuestionHelp with DataTable update Pin
Matthew Cuba15-Feb-07 5:23
Matthew Cuba15-Feb-07 5:23 
Hello,

I am trying to speed up the update of a DataTable. The short story is that I have a DataTable 'A' that has approximately 10-15 columns of information, depending on the data loaded. I have a couple of extra columns that get added to the table at runtime and I need to populate those columns based on the values in another table, 'B', that has 3 columns: an ItemID column for matching the ItemId column in table A and two other columns. I could have as many as 10K rows in DataTable A and the number of rows in DataTable B could vary. It is possible, too, that DataTable B may have rows where the ItemId doesn't match any ItemId in DataTable A, and it those instances, I want to ignore the rows.

My current solution involves something like this:


DataColumn aColNew1 = tableA.Columns["New1"];
DataColumn aColNew2 = tableA.Columns["New2"];
DataColumn bColNew1 = tableB.Columns["New1"];
DataColumn bColNew2 = tableB.Columns["New2"];
DataColumn bColItemId = tableB.Columns["ItemId"];

DataRow[] bRows = tableB.Select();

for (int i = 0; i < bRows.Length; ++i)
{
  DataRow[] aRows = tableA.Select("ItemId = '" + bRows[i][bColID].ToString() + "'");
  if (aRows.Length > 0)
  {
    aRows[0][aColNew1] = bRows[i][bColNew1];
    aRows[0][aColNew2] = bRows[i][bColNew2];
  }
}


Now, I'm am pretty new to C#, so this might not be the most efficient way to do this. I hope it isn't, because it is taking a considerable amount of time (close to 40 seconds) to execute this when tables A and B have around 10K rows.

Any suggestions on how I can speed this up would be much appreciated.

Thanks,
Matt
AnswerSolved Pin
Matthew Cuba15-Feb-07 8:49
Matthew Cuba15-Feb-07 8:49 
QuestionHow to: Broswse for directory through PropertyGrid Pin
SSMERK00715-Feb-07 3:58
SSMERK00715-Feb-07 3:58 
AnswerRe: How to: Broswse for directory through PropertyGrid Pin
JoeSharp15-Feb-07 4:05
JoeSharp15-Feb-07 4:05 
GeneralRe: How to: Broswse for directory through PropertyGrid Pin
SSMERK00715-Feb-07 4:57
SSMERK00715-Feb-07 4:57 
AnswerRe: How to: Browse for directory through PropertyGrid Pin
SSMERK00715-Feb-07 6:46
SSMERK00715-Feb-07 6:46 
QuestionSet &amp; Get in a C# Class Pin
allan.gagnon15-Feb-07 3:57
allan.gagnon15-Feb-07 3:57 
AnswerRe: Set &amp; Get in a C# Class Pin
Not Active15-Feb-07 4:07
mentorNot Active15-Feb-07 4:07 
GeneralRe: Set &amp; Get in a C# Class Pin
Colin Angus Mackay15-Feb-07 4:13
Colin Angus Mackay15-Feb-07 4:13 
GeneralRe: Set &amp; Get in a C# Class Pin
allan.gagnon15-Feb-07 4:32
allan.gagnon15-Feb-07 4:32 
GeneralRe: Set &amp; Get in a C# Class Pin
Not Active15-Feb-07 4:33
mentorNot Active15-Feb-07 4:33 
AnswerRe: Set &amp; Get in a C# Class Pin
Colin Angus Mackay15-Feb-07 4:12
Colin Angus Mackay15-Feb-07 4:12 
GeneralRe: Set &amp; Get in a C# Class Pin
allan.gagnon15-Feb-07 4:26
allan.gagnon15-Feb-07 4:26 
GeneralRe: Set &amp; Get in a C# Class Pin
allan.gagnon15-Feb-07 4:44
allan.gagnon15-Feb-07 4:44 
GeneralRe: Set &amp; Get in a C# Class Pin
Colin Angus Mackay15-Feb-07 5:32
Colin Angus Mackay15-Feb-07 5:32 
GeneralRe: Set &amp;amp;amp;amp; Get in a C# Class Pin
allan.gagnon16-Feb-07 3:19
allan.gagnon16-Feb-07 3:19 
Questionselecting image Pin
HexaDeveloper15-Feb-07 3:46
HexaDeveloper15-Feb-07 3:46 
QuestionHow can SqlDataReader implement IDisposable in .NET v1 when the Dispose method is private??!! Pin
cufc15-Feb-07 3:29
cufc15-Feb-07 3:29 

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.