ADO.NET

ADO.NET provides consistent access to data sources such as Microsoft SQL Server, as well as data sources exposed through OLE DB and XML. Data-sharing consumer applications can use ADO.NET to connect to these data sources and retrieve, manipulate, and update data.

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 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.

Data Provider

A data provider is used for connecting to a database, executing commands and retrieving data, storing it in a dataset, reading the retrieved data and updating the database.
The data provider in ADO.Net consists of the following four objects:
S.NObjects & Description
1Connection
This component is used to set up a connection with a data source.
2Command
A command is a SQL statement or a stored procedure used to retrieve, insert, delete or modify data in a data source.
3DataReader
Data reader is used to retrieve data from a data source in a read-only and forward-only mode.
4DataAdapter
This is integral to the working of ADO.Net since data is transferred to and from a database through a data adapter. It retrieves data from a database into a dataset and updates the database. When changes are made to the dataset, the changes in the database are actually done by the data adapter.
There are following different types of data providers included in ADO.Net
  • The .Net Framework data provider for SQL Server - provides access to Microsoft SQL Server.
  • The .Net Framework data provider for OLE DB - provides access to data sources exposed by using OLE DB.
  • The .Net Framework data provider for ODBC - provides access to data sources exposed by ODBC.
  • The .Net Framework data provider for Oracle - provides access to Oracle data source.
  • The EntityClient provider - enables accessing data through Entity Data Model (EDM) applications.

DataSet

DataSet is an in-memory representation of data. It is a disconnected, cached set of records that are retrieved from a database. When a connection is established with the database, the data adapter creates a dataset and stores data in it. After the data is retrieved and stored in a dataset, the connection with the database is closed. This is called the 'disconnected architecture'. The dataset works as a virtual database containing tables, rows, and columns.
The following diagram shows the dataset object model:
VB.Net Data Classes
The DataSet class is present in the System.Data namespace. The following table describes all the components of DataSet:
S.NComponents & Description
1DataTableCollection
It contains all the tables retrieved from the data source.
2DataRelationCollection
It contains relationships and the links between tables in a data set.
3ExtendedProperties
It contains additional information, like the SQL statement for retrieving data, time of retrieval, etc.
4DataTable
It represents a table in the DataTableCollection of a dataset. It consists of the DataRow and DataColumn objects. The DataTable objects are case-sensitive.
5DataRelation
It represents a relationship in the DataRelationshipCollection of the dataset. It is used to relate two DataTable objects to each other through the DataColumn objects.
6DataRowCollection
It contains all the rows in a DataTable.
7DataView
It represents a fixed customized view of a DataTable for sorting, filtering, searching, editing and navigation.
8PrimaryKey
It represents the column that uniquely identifies a row in a DataTable.
9DataRow
It represents a row in the DataTable. The DataRow object and its properties and methods are used to retrieve, evaluate, insert, delete, and update values in the DataTable. The NewRow method is used to create a new row and the Add method adds a row to the table.
10DataColumnCollection
It represents all the columns in a DataTable.
11DataColumn
It consists of the number of columns that comprise a DataTable.

No comments:

Post a Comment