Monday, April 16, 2012

DataTable.Copy Vs DataTable.Clone

Both the methods DataTable.Clone and DataTable.Copyare are used to make copies of existing datatables, the difference is

DataTable.Clone() - Copies only the structure of the source table with the constraints, the data is not copied from the source table.

DataTable.Copy() - Copies the structure and data from the source table.

DataTable targetTable;
targetTable = sourceTable.Clone();

Here, the targetTable is created with only the structure of the sourceTable
targetTable.Rows.Count() returns 0.

Example: DataTable.Copy()
DataTable targetTable;
targetTable = sourceTable.Copy();

Here, the targetTable is created with a copy of the structure and data from the sourceTable
targetTable.Rows.Count() returns the number of rows which were present in the sourceTable.

That’s it, we have seen the difference between DataTable.Copy() and DataTable.Clone()

Search Flipkart Products:


Cindy said...

Why clone humans, reasons against cloning. Click for more information.


lingmaaki said...

clone and copy example with source code


Lee Shin said...

spot on with this write-up, i like the way you discuss the things. i'm impressed, i must say. i'll probably be back again to read more. thanks for sharing this with us.

Lee Shin

Aissa said...

Nice post. Thank you for taking the time to publish this information very informative; so happy to be given a privilege to post a comment here.


sarah lee said...

I really enjoyed reading your article. I found this as an informative and interesting post, so i think it is very useful and knowledgeable. I would like to thank you for the effort you have made in writing this article.

Leslie Lim said...

I love this post, and I was absolutely thrilled to see the other links that you published that go along with this topic. Thank you for sharing your thoughts. I am happy to be a new follower. :)


joy said...

One thing I learned in life is to love what makes you happy and to cherish every moment you spend with your family, friends or love ones because everything that we have now on earth is temporary. Well, thank you for inspiring us with your great art work.
Visit my site for a very wonderful offer.

lee woo said...

Love it! Very interesting topics, I hope the incoming comments and suggestion are equally positive. Thank you for sharing this information that is actually helpful.

Silvia Jacinto said...

I am so glad to read your wonderful article. Im looking forward to read more of your works and posts. You did a good job! Try to visit my site too and enjoy.

Unknown said...

The first step toward success is taken when you refuse sto be a captive of the environment in which you first find yourself. Check my site also if you have time, I had a great time reading your article.

Kanye Co Jamila said...

Very much useful article. Kindly keep blogging

Java Training in Chennai

Java Online Training India