ADO.Net

ADO.NET

  • ADO stands for Activex Data Object.
  • It is Database Technologies of .Net basically it is used for connecting your application to your database server. 
  • We can Say it is a part of .Net Framework.
  • ADO.NET consist of classes to handle data access

  • The ADO.NET architecture is basically divided into 2 parts.

  1. Data Provider (connected objects or can say connection oriented objects).
  2. Data Set (Disconnected Objects or connection less objects). 

ADO.NET Architecture 



  • Data Providers(Connected Objects)
1)    SQLServer: -  
a. Namespace used: - using system.Data.SqlClient.
                             Example: - sqlserver 2008, 2012, and etc.

                             2)    OLEDB

                                    a.     NameSpace: - using system.data.Oledb
3)    ODBC
                                    a.     Namespace: - using system.data.Oledb
4) Oracle
                                     a. Namespace – using system.data.OracleClient.


      ·       The .Net Framework Data Provider is basically a component with help of it we can manipulate the data.
      ·       It is basically used for connecting to a database, executing commands and retrieving the result.
       ·       Data Provider has some class objects with help of this we can do this kind of stuff.

o   Connection.
o   Command.
o   Data Reader.

o   Data Adapter.


1)    Connection –
a.     It is the first component object of Ado.Net.
b.    It is basically used to provide connectivity to a data source.
c.     It is also used in accessing and manipulating databases.




·       Properties of Connection Objects.

·       Connection String: - it is basically a connection of name/Value pairs. Separated by semi-columns. Which gives us information about data source and with which connection needs to be established.
·       Data-Source: - it specifies the name of the computer name and SQL server with which connection is required.
·       Integrated security: - it ensures that the connection will be established using windows authentication.

·       Initial catalog: -it is basically the name of the Database.


          ·       Methods of Connection objects: -

o   Open ()-  this method will open the connection using information provided by connection String.

o   Close () - this method will close the connection which already exists.



1)    Command: -

This Command object is basically used to return data, modify data, and run Stored Procedure. And also used to send and retrieve parameter information.

We can execute SQL Queries to return data in Dataset or Data Reader objects.

Command Objects perform the standard Select, Insert, update and delete operations.


v Properties of Command Object: -

Connection: - It Specifies that on which connection command will execute.
Command Type: -   As per the name we can see that it will specify that which type of command we will execute.
           
o   Text – SQL Statement as command type.
o   Stored Procedure: -Stored Procedure as command type.



v Methods of Command Objects: -

ExecuteReader(): - This Method is basically used when we are using the select command. Or can say to select data from Database.

ExecuteNonQuery():- this method will return numbers of rows which are affected. It is used for insert, Update, Delete commands.

ExecuteScaler():-  It will return the first column of the first row of the result set. Remaining Rows and columns will be ignored.



1)    Data-Reader: -

§  ADO.Net Data Readers are basically used to retrieve a read-only, forward-only stream of data from the database.
§  Data reader objects work only in connected ways

  v Methods of Data Reader Objects: -

Read(): - This Method reads next row from DataReader Object. If Row Exist it will return true. Otherwise, it will return false.



1)    Data-Adapter: -

o   The data adapter provides bridge between the Data-Set and data source.
o   The Data Adaptor uses command objects to execute SQL-commands.

v Methods of Data-Adapter Objects: -

Fill (): - at first, it will take the result of Database Query from a command object. And then it will forward the data into dataSet. 

(Basically, we can say it will retrieve data from data source and fill it into the data table)

Update (): - It will update the database with the data modification made on a dataset object.



v DataSet (Disconnecred Objects)


o   Dataset is basically a tabular representation of data. Tabular representation means it represents data into row and column format.

o   This consist system.Data Namespace.

o   Dataset can hold records of more than one database tables or Data tables.

o   Dataset represents a complete set of data, including related tables, constraints, and the relationship between the tables.

o   No need for maintaining connection also.


One Thing to understand that Dataset has major 2 Objects

1)    Data table Collection: -
o   It contains all the data table objects in the dataset.
o   It contains a collection of the column which is represented by a data column collection.
o   And also contain constraint collection. Which together define the schema of the table.

2)    Data Relation Collection: -
o   It basically represents the relationship among two tables.
o   In simple term, we can provide the relationship with help of primary key and foreign key in the relational database.

o   A data relation identifies matching columns of two tables of the dataset.















Comments

Popular posts from this blog

Asp.Net Validation

Fundamental of OOPS From Scratch to End