System.Data.DataSet Class

Represents an in-memory cache of data.

See Also: DataSet Members


[System.ComponentModel.Designer("Microsoft.VSDesigner.Data.VS.DataSetDesigner, Microsoft.VSDesigner, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
[System.ComponentModel.ToolboxItem("Microsoft.VSDesigner.Data.VS.DataSetToolboxItem, Microsoft.VSDesigner, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public class DataSet : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable


The System.Data.DataSet, which is an in-memory cache of data retrieved from a data source, is a major component of the ADO.NET architecture. The System.Data.DataSet consists of a collection of System.Data.DataTable objects that you can relate to each other with System.Data.DataRelation objects. You can also enforce data integrity in the System.Data.DataSet by using the System.Data.UniqueConstraint and System.Data.ForeignKeyConstraint objects. For further details about working with System.Data.DataSet objects, see Using DataSets in ADO.NET.

Whereas System.Data.DataTable objects contain the data, the System.Data.DataRelationCollection allows you to navigate though the table hierarchy. The tables are contained in a System.Data.DataTableCollection accessed through the DataSet.Tables property. When accessing System.Data.DataTable objects, note that they are conditionally case sensitive. For example, if one System.Data.DataTable is named "mydatatable" and another is named "Mydatatable", a string used to search for one of the tables is regarded as case sensitive. However, if "mydatatable" exists and "Mydatatable" does not, the search string is regarded as case insensitive. For more information about working with System.Data.DataTable objects, see Creating a DataTable.

A System.Data.DataSet can read and write data and schema as XML documents. The data and schema can then be transported across HTTP and used by any application, on any platform that is XML-enabled. You can save the schema as an XML schema with the DataSet.WriteXmlSchema(System.IO.Stream) method, and both schema and data can be saved using the DataSet.WriteXml(System.IO.Stream) method. To read an XML document that includes both schema and data, use the DataSet.ReadXml(System.Xml.XmlReader) method.

In a typical multiple-tier implementation, the steps for creating and refreshing a System.Data.DataSet, and in turn, updating the original data are to:

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]

The System.Data.DataSet and System.Data.DataTable objects inherit from System.ComponentModel.MarshalByValueComponent, and support the System.Runtime.Serialization.ISerializable interface for remoting. These are the only ADO.NET objects that can be remoted.


Classes inherited from System.Data.DataSet are not finalized by the garbage collector, because the finalizer has been suppressed in System.Data.DataSet. The derived class can call the GC.ReRegisterForFinalize(object) method in its constructor to allow the class to be finalized by the garbage collector.


Namespace: System.Data
Assembly: System.Data (in System.Data.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0,