DataTables

  • Thread starter Thread starter bernardpace
  • Start date Start date
B

bernardpace

Hi,

I have a DataTable full of data. Now I am trying to clone it with its
schema and its data. A snippet of the code is shown below

DataTable original, cloned;

.... loads schema from an xsd file and loads data from an xml file
// original.Rows.Count is being found as 95 - correct
cloned = original.Clone();
// original.Rows.Count is being found as 95 - correct
// cloned.Rows.Count is being found as 0 - correct

When using the clone method, is the data found in the table also
cloned? If no, is there a way from cloning the data?



Can someone help me out
Thanks in Advance
 
When using the clone method, is the data found in the table also
cloned? If no, is there a way from cloning the data?

The DataTable.Clone() clone only the structure.

You need something like this:

// clone the structure
cloned = table.Clone();

// clone the data (eventually filtered/ordered)
foreach(DataRow r in table.Select(filter, orderBy))
cloned.ImportRow(r)
 
Back
Top