Database Reference
In-Depth Information
DataSet
:
DataSet
is the core architectural component of ADO.NET to make
disconnected applications. A data set can be considered a subset of data. A data
set supports disconnected, independent caching of data in a relational fashion,
updating the data source as required. A data set contains one or more data tables.
•
DataTable
:
DataTable
is a row-and-column representation that provides much the
same logical view as a physical table in a database. For example, you can store the
data from a database's table in an ADO.NET
DataTable
and manipulate the data as
needed.
•
DataRow
: As you know, a table always consists of rows. In a similar manner,
ADO.NET's
DataTable
consists of rows of the
DataRowCollection
type. This
DataRowCollection
is an enumerable collection of
DataRow
objects. When new data
is added to the
DataTable
, a new
DataRow
is added.
•
•
DataColumn
: Just like any other column in a database table, ADO.NET's
DataTable
consists of a
DataColumn
of the
DataColumnCollection
type.
DataView
:
DataView
in ADO.NET serves a purpose similar to a view in a database.
Usually a view in a databse provides a predefined, organized, or filtered set of
records. Similarly, a
DataView
provides filtered or sorted records from a
DataTable
.
Just like a database table can have multiple views, so too can the
DataTable
have
multiple data views on it.
•
Understanding .NET Data Providers
ADO.NET consists of various data providers that allow an easy and predefined object model to
communicate with various industry databases such as SQL Server, Oracle, Microsoft Access, and many
others.
There are various database providers, so each data provider has its own namespace. In fact, each
data provider is essentially an implementation of interfaces in the
System.Data
namespace, specialized
for a specific type of data source.
For example, if you use SQL Server, you should use the SQL Server data provider
(
System.Data.SqlClient
) because it's the most efficient way to access SQL Server.
The OLE DB data provider supports access to older versions of SQL Server as well as to other
databases, such as Access, DB2, MySQL, and Oracle. However, native data providers (such as
System.Data.OracleClient
) are preferable for performance, since the OLE DB data provider works
through two other layers, the OLE DB service component and the OLE DB provider, before reaching the
data source.
Figure 10-2 illustrates the difference between using the SQL Server and OLE DB data providers to
access a SQL Server database.