|Introduction : |
This Tutorial section enable yo to learn the basic concept of ADO.Net Object Model, ADO.Net provider and its type and its basic Components.
The ADO.Net Object Model
ADO.Net enables application to connect to data sources and manipulate the data. It is based on an Object model that is based on the standards laid down by the World Wide Web Consortium(W3C). This model has been designed in such a way that a developer can access and write to a widely variety of data sources such as Microsoft SQL Server and XML. By using ADO.Net data can be retrieved from one data source and saved in another. For example, the data can be retrieved from Microsoft excel and saved in XML document.
The following figure shows the ADO.Net object model.
In the ADO.Net object model, the data residing in a database is retrieved through a data provider. The data provider is a set of Components including the connection, command datareader and dataadapter objects. It provides data to the application and updates the database with the change made in the application. An application can access data either through a dataset or through a datareader object.
ADO.Net also enables to create an XML representation of a dataset. In an XML representation of a dataset,data is written in XML format and dataset schema is written by using the XML schema definition languages(XSD).
The two key component of the ADO.Net object model are
1) Data provider
A data provider is used for connecting to a database, retrieving data, storing the data in a dataset, reading the retrieved data and updating the database.
Selecting an appropriate data provider for a client application depend on the type of data source that is being accessed. The four main types of data provider are :
a) .Net Framework data provider for SQL server :- The .Net framework data provider for SQL server is used to work specially with Microsoft SQL server. The System.Data.dll assembly implements SQL server .Net framework data provider in the System.Data.SqlClient namespace.
b) .Net Framework data provider for OLEDB :- The .Net Framework data provider for OLEDB use native OLEDB through Component Object Model(COM) interoperability to enable data access. To use this type of provider, you must use an OLE DB provider. This type of data provider works with OLE DB provider Oracle OLE DB provider and the Het OleDB provider. The System.Data.dll assembly implements OLE DB .Net Framework data provider in the System.Data.Oledb namespace.
c) .Net Framework data Provider for ODBC :- The .Net framework data provider for ODBC used the Native ODBC Driver Manager through COM interoperability to enable data access. To use this type of provider, you must use an ODBC driver. The System.Data.ODBC.dll assembly implements ODBC .Net framework data provider. This assembly is not part of the Visual Studio .Net installation.
d) .Net Framework data provider for Oracle :- The .Net framework data provider for oracle enavle data access to oracle data sources through the oracle client connectivity software. Oracle client software must be installed on the system before you can use the provider to connect to an Oracle data source. The System.Data.OracleClient.dll namespace.
The dataset is a memory based relational representation of data. A dataset is a part of the disconnected environment. A dataset is disconnected, cached set of records that are retrieved from a database. A dataset contains a collection of one or more DatatTable objects made up of rows and Columns of data as well as Constraint and relation information about in the datatable objects.
A dataset is present in the DataSet class in the System.Data namespace. The Key Component of a dataset are :-
a) DataTableCollection :- it Contain all the tables retrieved from the DataSource.
b) DataRelationalCollection :- it Contain relationship and links between tables in a dataset.
c) DataTable :- it represent a table in the datatable Collection of a dataset.
d) DataRowCollection :- it Contains all the rows in a datatable.
e) DataColumnCollection :- it Contain all the columns in a datatable
An application can access data either through a dataset or thorough a datareader object :
A) Using a Dataset : In this case, the data is cached in a dataset and the application accesses the data from the dataset.
B) Using a DataReader : In this method, a datareader object, which is a component of the dataprovider, uses the connection object to connect to the database, uses the command object retrieve data and provides data to the application in a read-only and forward only mode.