Dataset Object in ADO.net:

May 11, 2011

Dataset is an in memory representation of database. Using DataAdapters we fetch data from database and dump into dataset. A dataset can hold multiple datatables in it and it can also store relation between them.
DataSets makes it easier to edit and update the information. Another good thing is that datasets are disconnected in nature so; if you make any changes to the dataset it will not reflect it in the database till you commit those changes. Dataset stores information in the form of XML.

Dataset methods:

WriteXML:

This method converts and gives data of dataset to a xml, you can get xml string or you can save it to xml file also.

WriteXMLSchema:

This method converts and gives schema of dataset to a xml, you can get xml string or you can save it to xml file also.

GetXML:

The GetXml() method returns the XML representation of the data from the DataSet.

GetXMLSchema:

This method gives XML schema of the dataset.

Code Example(SQL):

SqlConnection conn = new SqlConnection(""); SqlCommand com = new SqlCommand("select * from ", conn); SqlDataAdapter da = new SqlDataAdapter(com); DataSet ds=new DataSet(); da.Fill(ds);