Copying data from one DataTable to another?

You can't copy the whole table, you need to copy one rows. From support.microsoft.com/kb/308909 (sample code if you follow the link) How to Copy DataRows Between DataTables Before you use the ImportRow method, you must ensure that the target table has the identical structure as the source table. This sample uses the Clone method of DataTable class to copy the structure of the DataTable, including all DataTable schemas, relations, and constraints This sample uses the Products table that is included with the Microsoft SQL Server Northwind database.

The first five rows are copied from the Products table to another table that is created in memory.

You can't copy the whole table, you need to copy one rows. From support.microsoft.com/kb/308909 (sample code if you follow the link) "How to Copy DataRows Between DataTables Before you use the ImportRow method, you must ensure that the target table has the identical structure as the source table. This sample uses the Clone method of DataTable class to copy the structure of the DataTable, including all DataTable schemas, relations, and constraints.

This sample uses the Products table that is included with the Microsoft SQL Server Northwind database. The first five rows are copied from the Products table to another table that is created in memory.

It is not exactly a clone. I guess manually iterating through the datatable is the only option.. – Alex Sep 15 '08 at 23:50.

I need to explain a bit more. There is a filtering condition for copying the rows. So, a plain Copy() will not work.

– Alex Sep 15 '08 at 23:36.

Copying rows to a table throws some flags at me. I've seen people try this before, and in every single case what they really wanted was a System.Data.DataView. You really should check to see if the RowFilter property will do what you need it to do.

Would be great to see some sample code snippets. Edit: I need to explain a bit more. There is a filtering condition for copying the rows.

So, a plain Copy() will not work.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions