Convert Dataset to Datatable and Viceversa using asp.net
Sometimes we come across a Scenario we need to convert a Dataset to Datatable
and Datatable to Dataset in our Code to meet our required Solution. So this Article will helps to those who convert dataset to datatable and datatable to Dataset.
Sometimes we come across a Scenario we need to convert a Dataset to Datatable
and Datatable to Dataset in our Code to meet our required Solution. So this Article will helps to those who convert dataset to datatable and datatable to dataset.
Lets see the Piece of Code how it works ...
DataTable dstset = new DataTable();
dstset = getDataTableFromExcel(path);
DataTable dataTable = dstset.AsEnumerable().Skip(startLimit).Take(EndLimit).CopyToDataTable();
To Convert datatable to dataset. You know it theoretically a Dataset is nothing but combination of many datatable(s) so what i will do here is i will take one instance of the Dataset and add many Datatable(s) in to it.
dataTable = dstset.AsEnumerable().Skip(startLimit).Take(EndLimit).CopyToDataTable();
dst = new DataSet();
dst.Tables.Add(dataTable);
swxml = new System.IO.StringWriter();
dstset.TableName = "SoverignPartInfo";
dstset.WriteXml(swxml);
if (startLimit >= 1350)
{
}
string strpartDetails = swxml.ToString();
InsertedOracleDatabase(strpartDetails);
startLimit = startLimit + EndLimit;
Here is the Real time You can see how i add that...