vendredi 16 mars 2007

DataTable.Copy() <> DataTable.Clone()

If you want to copy a datatable schema with it's info, do :
DataTable.Copy()

If you only need to copy the schema without the info specified in the datarow, do :
DataTable.Clone()

As specified on msdn : http://msdn2.microsoft.com/en-us/library/system.data.datatable.clone.aspx

Both the Copy and the Clone methods create a new DataTable with the same structure as the original DataTable. The new DataTable created by the Copy method has the same set of DataRows as the original table, but the new DataTable created by the Clone method does not contain any DataRows.

Aucun commentaire: