-->

09 February 2020

Ado.Net

  Asp.Net CS By Example       09 February 2020
 Ado.Net 

 In this post we are leaning about ADO.NET. ADO.NET provides a Disconnected Model for database access. We store the information our interested in locally on the computer on which our C# program is running.

 Databases is used for data storage so the data can be fetch later via either a SQL query or a database application. Almost every software application running interacts with either one or multiple databases. Therefore, the front end needs a mechanism to connect with databases, and ADO.NET is used for that purpose. Most of the .NET applications that require database functionality are dependent on ADO.NET.

  Ado.Net:
ADO.NET

 ADO.NET Provide 2 set of classes for disconnected database access.
   ◆ Generic data classes
   ◆ Managed provider classes

  • Generic Data Classes and Objects:
  •    The generic data objects enable we to store a local copy of the information stored in the database.
    The following are some of the generic data classes:

    Sr.No Property Description
    1) DataSet We use an object of the DataSet class to represent a local copy of the information stored in the database. It has the capability of representing database structures such as tables, rows, and columns, among others. We can also use a DataSet object to represent XML data.
    2) DataTable We use an object of the DataTable class to represent a table. We can store multiple DataTable objects in a DataSet.
    3) DataRow We use an object of the DataRow class to represent a row. We can store multiple DataRow objects in a DataTable.
    4) DataColumn We use an object of the DataColumn class to represent a column. We can store multiple DataColumn objects in a DataRow.
    5) DataRelation We use an object of the DataRelation class to represent a relationship between two DataTable objects. We can use a DataRelation object to model parent-child relationships between two database tables. We can store multiple DataRelation objects in a DataSet.
    6) Constraint We use an object of the Constraint class to represent a database constraint— such as unique values for a column or that a particular column is a foreign key into another table. We can store multiple Constraint objects in a DataTable.
    7) DataView We use an object of the DataView class to view only specific rows in a DataTable object using a filter. We can store multiple DataView objects in a DataSet.

     The DataSet, DataTable, DataRow, DataColumn, DataRelation, Constraint, and DataView classes are all declared in the System.Data namespace.

  • Managed Provider Classes and Objects
  •    The managed provider objects allow we to directly access a database. We use the managed provider objects to connect to the database and to read and write information to and from the database.
    The following are some of the managed provider classes:

    Sr.No Property Description
    1) Connection Classes We use an object of the SqlConnection class to connect to a SQL Server database. You use an object of the OleDbConnection class to connect to any database that supports OLEDB (Object Linking and Embedding for Databases), such as Access or Oracle. You use an object of the OdbcConnection class to connect to any database that supports ODBC (Open Database Connectivity). All the major databases support ODBC, but ODBC is typically slower than the other two options when working with .NET.
    2) Command Classes We use an object of the SqlCommand, OleDbCommand, or OdbcCommand class to represent a SQL statement or stored procedure call that we then execute using one of the appropriate connection classes.
    3) DataReader Classes We use an object of the SqlDataReader, OleDbDataReader, or OdbcDataReader class to read rows retrieved from a SQL Server, OLEDB-compliant, or ODBC-compliant database, respectively. We use these objects to read rows in a forward direction only and to act as an alternative to a DataSet. Reading data using these objects is typically faster than using a DataSet.
    4) DataAdapter Classes We use an object of the SqlDataAdapter, OleDbDataAdapter, or OdbcDataAdapter class to move rows between a DataSet object and a SQL Server, OLEDB-compliant, or ODBC-compliant database, respectively. We use one of these data adapters to synchronize our locally stored information with the database.
    5) Transaction Classes We use an object of the SqlTransaction, OleDbTransaction, or OdbcTransaction class to represent a database transaction in a SQL Server, OLEDB-compliant, or ODBC-compliant database, respectively.

    logoblog

    Thanks for reading Ado.Net

    Previous
    « Prev Post

    No comments:

    Post a Comment

    Please do not enter any spam link in the comment box.