UNIT -V
ADO.NET
1.1. Database:
A database is a collection related data - a collection of records—that is, rows of records,
where each column is a field—becomes a table. Relational database are set up to relate the
data in multiple tables together. To make a table relational, you choose certain fields to be
primary keys and foreign keys.
ADO.NET is a set of classes that expose data access services with rich set of components for
creating distributed, data-sharing applications. Microsoft ActiveX Data Objects.Net
(ADO.Net) is a model, a part of the .Net framework that is used by the .Net applications for
retrieving, accessing and updating data.
1.2. ADO.Net Object Model
ADO.Net object model is nothing but the structured process flow through various
components. The object model can be pictorially described as:
ADO.NET data Objects
The data residing in a data store or database is retrieved through the data provider. Various
components of the data provider retrieve data for the application and update data.
An application accesses data either through a dataset or a data reader.
Datasets store data in a disconnected cache and the application retrieves data from it.
Data readers provide data to the application in a read-only and forward-only mode.
2.0. ADO.NET Objects
Here's a list of the most common ADO.NET objects:
Data connection objects—To start working with a database, you must have a data
connection. A data adapter needs a connection to a data source to read and write data,
, Programming with Visual Basic
and it uses OleDbConnection or SqlConnection objects to communicate with a data
source.
Data adapters—Data adapters are a very important part of ADO.NET. You use them
to communicate between a data source and a dataset. You typically configure a data
adapter with SQL to execute against the data source. The two types of data adapters
are OleDbDataAdapter and SqlDataAdapter objects.
Command objects—Data adapters can read, add, update, and delete records in a data
source. To allow you to specify how each of these operations work, a data adapter
contains command objects for each of them. Data adapters support four properties that
give you access to these command objects: SelectCommand, InsertCommand,
UpdateCommand, and DeleteCommand.
Datasets—Datasets store data in a disconnected cache. The structure of a dataset is
similar to that of a relational database; it gives you access to an object model of
tables, rows, and columns, and it contains constraints and relationships defined for the
dataset. Datasets are supported with DataSet objects.
DataTable objects—DataTable objects hold a data table from a data source. Data
tables contain two important properties: Columns, which is a collection of the
DataColumn objects that represent the columns of data in a table, and Rows, which
is a collection of DataRow objects, representing the rows of data in a table.
Data readers— DataReader objects hold a read-only, forward-only (i.e., you can
only move from one record to the succeeding record, not backwards) set of data from
a database. Using a data reader can increase speed because only one row of data is in
memory at a time.
Data views—Data views represent a customized view of a single table that can be
filtered, searched, or sorted. In other words, a data view, supported by theDataView
class, is a data "snapshot" that takes up few resources.
Constraint objects—Datasets support constraints to check data integrity. A
constraint, supported by the Constraint class, is a rule that can be used when rows are
inserted, updated, or deleted to check the affected table after the operation. There are
two types of constraints: unique constraints check that the new values in a column are
unique throughout the table, and foreign-key constraints specify how related records
should be updated when a record in another table is updated.
DataRelation objects—DataRelation objects specify a relationship between parent
and child tables, based on a key that both tables share.
DataRow objects—DataRow objects correspond to a particular row in a data table.
You use the Item property to get or set a value in a particular field in the row.
DataColumn objects—DataColumn objects correspond to the columns in a table.
Each object has a DataType property that specifies the kind of data each column
contains, such as integers or string values.