UNIT 4 - ADO.NET
UNIT 4 - ADO.NET
NET
UNIT -4
Mrs.K.Muthu Lakshmi
Assistant Professor
Department of Information Technology
Introduction to Ado.Net
• Ado stands for Active Database Object
• Before Ado.net we use Ado to access data from database.
Basically Ado has automatic driver detection technique
and its has only one drawback that it only provide a
connected environment so efficiency system may
decrease.
• ADO.NET is a new database technology used by .Net
platform (introduced in 2o02).
• In fact it is a set of classes used to communicate between
an application front end and a database.
• It support both connected & disconnect mode of data
access.
Difference between ADO and ADO.NET
ADO ADO.NET
It is a COM based library. It is a CLR based library.
Classic ADO require active connection ADO.NET architecture works while the
With the data store. data store is disconnected.
Locking feature is available. Locking feature is not available.
Data is stored in Binary format. Data is stored in XML format.
XML integration is not possible. XML integration is possible.
It uses the object named Recordset to It uses the Dataset object for data access
reference data from the data store. and representation.
Firewall might prevent execution of ADO.NET has firewall proof and its
classic ADO. execution will never be interrupted.
Classic ADO architecture includes client ADO.NET architecture doesn’t include
side cursor and server side cursor. such cursor.
Namespaces used in ADO.Net
• System.Data
It contains the common classes for connecting, fetching data from
database. Classes are like as Data Table , Dataset , Dataview etc.
• System.Data.SqlClient
It contain classes for connecting fetching data from Sql server database.
Classes are like as SqlDataAdapter , SqlDataReader etc.
• System.Data.OracleClient
It contain classes for connecting fetching data from Oracle database.
Classes are like as OracleDataAdapter , OracleDataReader etc.
• System.Data.OleDb
It contain classes for connecting , fetching data from any database (like
Ms Access , db2 , Oracle , Sqlserver , mySql). Classes are like as
OleDbDataAdapter , OleDbDataReader , etc.
ADO.NET Architecture
Component of ADO.NET
• The two key components of ADO.NET are
Data Providers
DataSet
DataSet
• Basically it is a small Data structure that may contain multiple
datatables from multiple sources.
• The information in dataset is created inform of XML and is
stored with .xsd extention .
• It support disconnected mode of data access . It has both
Scrolling mode means forward and backward scrolling
mode(fetching of data).
• DataSet can have multiple Database is able to read only single
Database.
Creating and using a DataSet
• The typing steps in creating and using a Dataset are:
(i ) Create a DataSet object.
(ii) Connect to a database.
(iii) Fill the DataSet with one or more tables or
views.
(iv) Disconnect from the database.
(v) Use the DataSet in the application.
Data Provider
• Data provider is a set of ADO.Net classes that allow us to
access a database. Basically, it is a bridge between our
application (we can say front-end) and data source.
There are following Data provider:
Sqlserver Data Provider :- It is used to access data from
sqlserver database (for version 7.0 or later).
Oracle Data Provider:- It is used to access data from
oracle database (for version 8i or later).
OleDb Data Provider:- It is used to access data from any
database (msaccess , mysql , db2).
Odbc Data Provider:- It is used to access data from any
database (msaccess).
• The four objects from the .Net Framework provides
the functionality of Data Providers in the ADO.NET.
They are
connection Object.
command Object.
Data Reader Object.
Data Adapter Object.
The SQL Connection Object
• The Connection :- The Connection object which
provides a connection to the database.
Sqlconnection con= new Sqlconnection{
“Data source=(local);
Initial Catalog=Emp;
Integrated seurity=sspi”);
• There are four connection string Parameter Name:
Data Source Data source Identifiers the server and it could be local
machine domain name, or IP Address.
Initial Catalog Database name.
Integrated Security Integrated Security set to SSPI to make
connection with user’s windows login
• User ID Name of user configured in SQL Server.
• Password Password matching SQL Server User ID.