How do I copy one dataset table to another dataset table?

  • Thread starter Thread starter Top Gun
  • Start date Start date
Keeping in mind that datatables are Reference types and the copy is simply
a copy of the reference (ie any changes you make to the copy will be
reflected in the original), this should work for you:

Dim dt As New DataTable

Dim dt2 As New DataTable

Dim ds1 As New DataSet

Dim ds2 As New DataSet

ds1.Tables.Add(dt)

dt2 = dt.Copy()

ds2.Tables.Add(dt2)



However, you can make a deep copy wherin you create a new table and set each
value of the new field to the value of the sourdce...
 
Hi Bill are you sure of that?
Keeping in mind that datatables are Reference types and the copy is simply
a copy of the reference (ie any changes you make to the copy will be
reflected in the original), this should work for you:

Datatable.copy
A new DataTable with the same structure (table schemas and constraints) and
data as this DataTable.

What you say is as far as I know.
DataTable Dt;
Dt = DtOld;

But maybe I am wrong?

:-)

Cor
 
Back
Top