G
Guest
All,
Can anyone help me understand the best way to copy all rows from an existing
DataTable into a second DataTable which also has existing rows. The following
code takes 6-7 seconds for 1200 rows in sourceTable and 1 or more rows in
destinationTable. If there are 0 rows in destinationTable, the code runs in 1
second or less. How can I get the run time down when there are rows in
destinationTable?
TIA,
-- MN.
Dim sourceTable As DataTable
Dim destinationTable As DataTable
Dim existingRow As DataRow
destinationTable.BeginLoadData()
For Each existingRow In sourceTable.Rows
newRow(0) = existingRow(0)
newRow(1) = existingRow(1)
newRow(2) = existingRow(2)
destinationTable.LoadDataRow(newRow, False)
Next
sourceTable.Clear()
destinationTable.EndLoadData()
destinationTable.AcceptChanges()
Can anyone help me understand the best way to copy all rows from an existing
DataTable into a second DataTable which also has existing rows. The following
code takes 6-7 seconds for 1200 rows in sourceTable and 1 or more rows in
destinationTable. If there are 0 rows in destinationTable, the code runs in 1
second or less. How can I get the run time down when there are rows in
destinationTable?
TIA,
-- MN.
Dim sourceTable As DataTable
Dim destinationTable As DataTable
Dim existingRow As DataRow
destinationTable.BeginLoadData()
For Each existingRow In sourceTable.Rows
newRow(0) = existingRow(0)
newRow(1) = existingRow(1)
newRow(2) = existingRow(2)
destinationTable.LoadDataRow(newRow, False)
Next
sourceTable.Clear()
destinationTable.EndLoadData()
destinationTable.AcceptChanges()