|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Fastest DataRow Copy?I have two DataSets and need to get DataRows from one DataTable into
another. Is this the fastest way? I am after pure speed no matter what the "cost", in this case. DataRow[] dataRows = oldSet.Tables["OldTable"].Select(); for ( int dwC=0 ; dwC < dataRows.Length ; dwC++ ) { DataRow newRow = newSet.Tables["NewTable"].NewRow(); newuRow.ItemArray = dataRows[dwC].ItemArray; } newSet.Tables["NewTable"].AcceptChanges(); Thanks. Localhost,
I never tested it, however I think that the datatable.copy will be the fastest. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatatableclasscopytopic.asp I hope this helps? Cor Show quote "localhost" <primpi***@cohort.ces> schreef in bericht news:t7qfr0t5mbrgkkf5mfppi3ui5ejg962jkg@4ax.com... > > I have two DataSets and need to get DataRows from one DataTable into > another. Is this the fastest way? I am after pure speed no matter > what the "cost", in this case. > > > DataRow[] dataRows = oldSet.Tables["OldTable"].Select(); > for ( int dwC=0 ; dwC < dataRows.Length ; dwC++ ) > { > DataRow newRow = newSet.Tables["NewTable"].NewRow(); > newuRow.ItemArray = dataRows[dwC].ItemArray; > } > newSet.Tables["NewTable"].AcceptChanges(); > > > > Thanks. > > Thanks, but I need to append data from one DataTable into another one,
I don't want a copy because that will destroy what's already in the destination table. Looking for any tricks to do the fastest insert/append possible between DataTables in different DataSets. Thanks. On Thu, 9 Dec 2004 10:24:37 +0100, "Cor Ligthert" <notmyfirstn***@planet.nl> wrote: Show quote >Localhost, > >I never tested it, however I think that the datatable.copy will be the >fastest. > >http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatatableclasscopytopic.asp > >I hope this helps? > >Cor > >"localhost" <primpi***@cohort.ces> schreef in bericht >news:t7qfr0t5mbrgkkf5mfppi3ui5ejg962jkg@4ax.com... >> >> I have two DataSets and need to get DataRows from one DataTable into >> another. Is this the fastest way? I am after pure speed no matter >> what the "cost", in this case. >> >> >> DataRow[] dataRows = oldSet.Tables["OldTable"].Select(); >> for ( int dwC=0 ; dwC < dataRows.Length ; dwC++ ) >> { >> DataRow newRow = newSet.Tables["NewTable"].NewRow(); >> newuRow.ItemArray = dataRows[dwC].ItemArray; >> } >> newSet.Tables["NewTable"].AcceptChanges(); >> >> >> >> Thanks. >> >> > > Thanks, but I need to append data from one DataTable into another one, You did not say that, than is this one probably the best> I don't want a copy because that will destroy what's already in the > destination table. > importrow http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatatableclassimportrowtopic.asp I hope this helps? Cor |
|||||||||||||||||||||||