Home > DeveloperSection > Blogs > What is DataSet?

What is DataSet?


ADO.Net ADO.Net 
Ratings:
2 Comment(s)
 2603  View(s)
Rate this:

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"]};

 


DataSet

By Uttam Misra on   6 years ago
John, really useful for the beginners.


Nice blog.

By marcel ethan on   3 years ago
Nice blog.

Don't want to miss updates? Please click the below button!

Follow MindStick