Chapter 6. DataSets
The DataSet
is a
memory-resident representation of data including tables,
relationships between the tables, and both unique and foreign key
constraints. It is used for working with and transporting data in a
disconnected environment.
There are four important characteristics of the
DataSet
:
It’s not provider-specific. It’s impossible to tell by looking at the
DataSet
, or at the objects contained within theDataSet
, which provider was used to retrieve the data or what the original data source was. TheDataSet
provides a consistent programming model regardless of the data source.It’s always disconnected. Information is retrieved from the data source and placed in the
DataSet
using another ADO.NET object—theDataAdapter
. At no point does aDataSet
directly reference aConnection
object.It can track changes made to its data. The
DataSet
contains multiple versions of each row of data in the tables, which allows changes to be updated back to the data source using aDataAdapter
object, changes to be cancelled, and XML DiffGrams of the changes to be created.It can contain multiple tables. Unlike the traditional ADO
Recordset
, theDataSet
approximates a relational database in memory.
DataSets
exist as both untyped and
strongly typed. Strongly typed
DataSet
s are a collection of automatically
generated classes that inherit from the DataSet
,
DataTable
, and DataRow
classes,
and provide additional properties, methods, and events based on the
DataSet
schema. A strongly ...
Get ADO.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.