Here is example that how to copy a DataTable to DataSet from another DataSet.
oDs is our original DataSet and it contains one table in it. Now create another dataset oDsNew using
DataSet oDsNew = new DataSet();
Now check if dataset is not empty.
Use .Add method to Copy table from another dataset. Please note that you have to use Copy function from original Dataset.
oDsNew.Tables.Add(oDs.Tables[0].Copy());
Original Code:
//Now we have one dataset with and it have one datatable inside
DataSet oDs = getData();
//We have to copy it
DataSet oDsNew = new DataSet();
if (oDs != null && oDs.Tables.Count > 0)
{
oDsNew.Tables.Add(oDs.Tables[0].Copy());
}
0 comments:
Post a Comment