Friday, January 23, 2009

ADO.Net Overview

ADO.net is the new way to manipulate data that is based on disconnected data and XML. Disconnected datasets reduce network traffic

ADO.net objects are

Connection Objects

Connection objects are used to connect to databases. They have properties, such as
DataSource, UserID, and Password, which are needed to access a particular DataSource.

There are two kinds of connection objects in ADO.NET: SqlConnection and OleDbConnection.

Command Objects

Command objects contain the information that is submitted to a database. A
command can be a stored procedure call, an update statement, or a statement
that returns results. You can also use input and output parameters and return
values. In ADO.NET, you can use two kinds of command objects:
SqlCommand and OleDbCommand.

DataReader Objects

A DataReader is a read-only/forward-only view on the data. It provides a
simple and lightweight way of traversing through recordsets

A DataReader is returned after executing a command. It works similarly to a
recordset in ADO, allowing you to simply loop through the records.

ADO.NET includes two types of DataReader objects: the SqlDataReader for
Microsoft SQL Server™ version 7.0 (or later) data, and the OleDbDataReader
for ADO data. The DataReader object is database-specific. The behavior for
the SqlDataReader may differ from the behavior for the OleDbDataReader
and additional DataReader objects that are introduced in the future.
You use the OleDbCommand and SqlCommand objects and the
ExecuteReader method to transfer data into a DataReader.

DataSet Objects

The DataSet is designed to handle the actual data from a data store. The
DataSet provides a rich object model to work with when passing data between
various components of an enterprise solution. The DataSet object is generic.
The behavior of a DataSet is completely consistent regardless of the underlying
database, SQL or OLE DB.
The DataSet object represents a cache of data, with database-like behavior. It
contains tables, columns, relationships, constraints, and data. Data coming from
a database, an XML file, code, or user input can be entered into DataSet
objects and converted into files, forms, or databases. As changes are made to
the DataSet, they are tracked in a way similar to the way changes are tracked in
a word processing document.
The DataSet object has a collection of DataTable objects. A DataTable
represents one table of in-memory data. It contains a collection of columns that
represents the table's schema. A DataTable also contains a collection of rows,
representing the data contained in the table.
You use the OleDbDataAdapter and SqlDataAdapter objects and the Fill
method to get data into a DataSet.



DataView Objects


A DataView provides a custom view of a data table. You can think of the
DataView as the equivalent of the ADO disconnected recordset, because it
contains a single view on top of the table data. You can use a DataView to
specify criteria for filtering and sorting a DataSet.

DataAdapter Object

The DataAdapter object allows for the retrieval and saving of data between a DataSet object and the source datastore. It is responsible for pulling out data from the physical store and pushing it
into data tables and relations. The DataAdapter object is also responsible for
transmitting any update, insertion, or deletion to the physical database. You can
use four command objects to make any updates: UpdateCommand,
InsertCommand, DeleteCommand, and SelectCommand.

The DataAdapter object exists in two forms: SqlDataAdapter objects and
OleDbDataAdapter objects. The data source is SQL Server for
SqlDataAdapter objects and any other OLE DB provider for
OleDbDataAdapter objects.


Difference between Recordset and Dataset

Feature----------------- Recordset-------------------------- DataSet
Number of tables-------- One table -------- -------- -------- -- Multiple tables
Relationships-------- ---- Based on join -------- -------- ------- Includes relationships
Moving through data -- Move row-by-row -------- --------Navigate via relationships
Data connections -------- Connected -------- -------- -------Disconnected
Transmitting data ---------COM marshalling -------- ---------- Transmit XML file



NameSpaces required for ADO.Net

Namespace ---------------------------------------Contains
System.Data ---------------------------------------Base objects and types for ADO.NET
System.Data.OleDb-------------------------------Managed OLE DB data store objects
System.Data.SqlClient -------------------------- SQL Server specific implementations of ADO.NET objects
System.Data.XML ------------------------------ XML objects
System.Data.SqlTypes ------------------------- SQL data types

No comments:

Post a Comment