Databases Reference
In-Depth Information
The architecture mirrors the logical design of a relational database. You'll see how to
use data tables, data rows, and data columns in this chapter.
A Brief Introduction to Data Adapters
When you first instantiate a dataset, it contains no data. You obtain a populated dataset
by passing it to a data adapter, which takes care of connection details and is a component
of a data provider. A dataset isn't part of a data provider. It's like a bucket, ready to be
filled with water, but it needs an external pipe to let the water in. In other words, the
dataset needs a data adapter to populate it with data and to support access to the data
source.
Each data provider has its own data adapter in the same way that it has its own con-
nection, command, and data reader. Figure 13-2 depicts the interactions between the
dataset, data adapter, and data source.
Figure 13-2. Dataset, data adapter, and data source interaction
The data adapter constructor is overloaded. You can use any of the following to get
a new data adapter. We're using the SQL Server data provider, but the constructors for the
other data providers are analogous.
SqlDataAdapter da = new SqlDataAdapter();
SqlDataAdapter da = new SqlDataAdapter(cmd);
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
SqlDataAdapter da = new SqlDataAdapter(sql, connString);
So, you can create a data adapter in four ways:
Search WWH ::




Custom Search