blog

Home / DeveloperSection / Blogs / What is DataSet?

What is DataSet?

John Smith4959 27-Sep-2010

The DataSet, which is anin-memory cache of data retrieved from a data source, is a major component ofthe ADO.NET architecture. The DataSet consists of a collection of DataTable objects that you can relate toeach other with DataRelation objects.

A DataSet can read and writedata and schema as XML documents. The data and schema can then be transportedacross HTTP and used by any application, on any platform that is XML-enabled.You can save the schema as an XML schema, and both schema and data can be saved.To read an XML document that includes both schema and data, use the ReadXMLmethod.

Herefirst we will see how we can create dataset:

Syntax:

               DataSet datasetobjectname = new DataSet();  

Herewe can add table in the DataSet:

Syntax:
               datasetobjectname.Tables.Add(datatable);

Herehow we can delete DataTable from dataset:

Syntax:
               Datasetname.Tables.Remove(datasetobjectname.Tables[position]);

Setting primary key for a Datatable:

 datatable.PrimaryKey = new DataColumn[] { datatable.Columns["ID"]};


Updated 18-Sep-2014
I am best.

Leave Comment

Comments

Liked By