By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,207 Members | 1,028 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,207 IT Pros & Developers. It's quick & easy.

DataTables

P: n/a
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

Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
<be*********@yahoo.com> ha scritto nel messaggio
news:11*********************@o13g2000cwo.googlegro ups.com...
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)

--
Reporting tool: http://www.neodatatype.net
Nov 17 '05 #2

P: n/a
Thanks for your help, problem solved

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.