0
33kviews
Explain ADO.NET object model with suitable diagram.

Mumbai University > Information Technology > Sem 4 > Web Programming

Marks: 10M

Year: May 2015

1 Answer
6
1.3kviews

enter image description here

ADO.NET Object Model:

  • All ADO.NET related functionality appears under the System. Data namespace.
  • Data Access in ADO.NET relies on two components :

    1. .NET Data Providers.
    2. Dataset

NET Data Providers:

  • A .NET Data Provider is responsible for providing and maintaining the connection to the database.
  • Following are the various .NET Data Providers:
  1. .NET Framework Data Provider for SQL Server.
  2. .NET Framework Data Provider for Oracle.
  3. .NET Framework Data Provider for OLE DB.
  4. .NET Framework Data Provider for ODBC.
  5. The .NET Framework Data Provider for SQL Server uses its own protocol to communicate with SQL server. The classes for this provider are located in System.Data.SqlClient namespace.
  6. Each Data Provider provides the following core objects:

    A. Connection

    B. Command

    C. Data Reader

    D. Data Adapter

    A. Connection:

    • This is the object that allows you to establish a connection with the data source.
    • Depending on the actual .NET Data Provider involved, connection objects automatically pool physical databases connections for you.
    • Examples of connection objects are OleDbConnection, SqlConnection, OracleConnection and so on.

    B. Command:

    • This object represents an executable command on the underlying data source. The command may or may not return any results. These commands can be used to manipulate existing data.
    • In addition, the commands can be used to manipulate underlying table structures.
    • Examples of command objects are SqlCommand, OracleCommand and so on. A Command needs to be able to accept parameters. The Parameter object of ADO.NET allows commands to be more flexible and accept input values and act accordingly.

    C. Data Reader:

    • This object is designed to help you retrieve and examine the rows returned by the query as quickly as possible.
    • DataReader object examines the results of a query one row at a time. When you move forward to the next row, the contents of the previous row are discarded.
    • The DataReader doesn’t support updating. The data returned by the DataReader is read-only. Because the DataReader object supports such a minimal set of features, it is extremely fast and lightweight.
    • The disadvantage of using a DataReader object is that it requires an open database connection and increases network activity.

    D. DataAdapter:

    • This object acts a gateway between the disconnected and connected flavours of ADO.NET. The architecture of ADO.NET, in which connection must be opened to access the data retrieved from the database is called as connected architecture whereas as in a disconnected architecture data retrieved from database can be accessed by holding it in a memory with the help of DataSet object even when the connection is closed.
    • Examples of Data Adapters are SqlDataAdapter, OracleDataAdapter and so on. It has commands like Select, Insert, Update and Delete .
    • Select command is used to retrieve data from the database and insert, update and delete commands are used to send changes to the data in dataset to database.

DataSet :

  • It is an in-memory cache of data retrieved from the data source. Data is organized into multiple tables using DataTable objects, tables can be related using DataRelation objects and data integrity can be enforced using the constraint objects like UnqueConstraint and ForeignKeyConstraint.
  • DataSet are also fully XML-featured. They contain methods such as GetXML and WriteXML that respectively produce and consume XML data easily.
  • The DataSet object provides a consistent programming model that works with all the current models of data storage: flat, relational and hierarchical.
  • Another feature of DataSet is that it tracks changes that are made to the data it holds before updating the source data.
  1. DataTable : A DataSet object is made up of a collection of tables, relationships, and constraints. In ADO.NET, DataTable objects are used to represent the tables in a DataSet object.
  2. DataColumn : Each DataTable object has a Columns collection, which is a container for DataColumn objects. A DataColumn object corresponds to a column in a table.
  3. DataRow : To access the actual values stored in a DataTable object, use the object’s Rows collection, which contains a series of DataRow objects.
  4. DataView : Once we have retrieved the results of a query into a DataTable object, we can use a DataView object to view the data in different ways. In order to sort the content of the DataTable object based on a column, simply set the DataView object’s Sort property to the name of that column. Similarly the Filter property of the DataView can be used so that only the rows that match certain criteria are visible.
  5. DataRelation : A DataSet, like a database, might contain various interrelated tables. A DataRelation object lets you specify relations between various tables that allow you to both validate data across tables and browse parent and child rows in various Data Tables.
Please log in to add an answer.