---
title: "What is DataSet?"  
description: "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"  
author: "John Smith"  
published: 2010-09-27  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/10/what-is-dataset  
category: "ado.net"  
tags: ["ado.net"]  
reading_time: 1 minute  

---

# What is DataSet?

The DataSet, which is anin-memory cache of data retrieved from a [data source](https://www.mindstick.com/interview/808/what-is-a-data-source), is a major [component](https://www.mindstick.com/articles/12262/learn-how-to-make-a-component-in-magento-2) ofthe ADO.NET architecture. The DataSet consists of a [collection](https://www.mindstick.com/articles/1718/collections-in-java) of [DataTable](http://msdn.microsoft.com/en-us/library/system.data.datatable%28v=vs.71%29.aspx) objects that you can relate toeach other with [DataRelation](http://msdn.microsoft.com/en-us/library/system.data.datarelation%28v=vs.71%29.aspx) objects.

A DataSet can read and writedata and schema as XML documents. The [data and schema](https://www.mindstick.com/forum/161690/what-are-structured-data-and-schema-markup) can then be transportedacross HTTP and used by any [application](https://www.mindstick.com/articles/12824/calculator-application-in-android), on any [platform](https://www.mindstick.com/articles/13080/wikipedia-the-most-powerful-advertising-platform-of-the-digital-age) 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](https://www.mindstick.com/articles/328642/what-to-consider-while-choosing-a-software-documentation-tool) that includes both schema and data, use the [ReadXML](http://msdn.microsoft.com/en-us/library/system.data.dataset.readxml%28v=vs.71%29.aspx)method.

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"]};

---

Original Source: https://www.mindstick.com/blog/10/what-is-dataset

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
