Click here to Skip to main content
16,012,107 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have datatable dt_vendor
i want to transfer all the data from dt_vendor to dataset ds["vendor"]
Posted

Easy way: Add the DataTable to the DataSet object:
C#
DataTable originalData = LoadDataTableFromExcel(path);
DataSet ds = new DataSet();
originalData.TableName = "vendor";
ds.Tables.Add(originalData);
DataTable dt = ds.Tables["vendor"];
 
Share this answer
 
Quote:
i want to transfer all the data from dt_vendor to dataset ds["vendor"]
I am interpreting this a bit differently than the others have and assume that you literally want to transfer each row from dt_vendor into a table named "vendor" in the dataset "ds".

C#
for (int i = dt_vendor.Rows.Count - 1; i > -1; i -= 1)
{
    ds.Tables["vendor"].ImportRow(dt_vendor.Rows[i]);
    dt_vendor.Rows[i].Delete();
}
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900