Topic: ADO. Net Framework

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 10

Topic: ADO.

Net
Framework
ADO. Net-Overview
Microsoft ActiveX Data Objects.Net (ADO.Net) is a model, and a part of the
.Net framework that is used by the .Net applications for retrieving, accessing
and updating data.
ADO.NET provides a bridge between the front end controls and the back
end database.
Applications communicate with a database,
Firstly, to retrieve the data stored there and present it in a user-friendly way
Secondly, to update the database by inserting, modifying and deleting data.
ADO. Net
The following are a few of the .NET applications that use ADO.NET to
connect to a database, execute commands and retrieve data from the
database.
ASP.NET Web Applications
Console Applications
Windows Applications.
ADO. Net Architecture
ADO.NET Classes
Various important classes in the preceding diagram are:
Connection Class
Command Class
DataReader Class
DataAdaptor Class
DataSet.Class
ADO. Net Connection Class
1. Connection Class
In ADO.NET, we use these connection classes to connect to the database.

Syntax:
String constr="server=SYSTEM-NAME; initial catalog=DATABASE-NAME; integrated
security=true”;
SqlConnection conn=new sqlconnection(constr);
ADO. Net Command Class
2. Command Class
  The Command class provides methods for storing and executing SQL statements.
 The following are the various commands that are executed by the Command Class.
 ExecuteReader: Returns data to the client as rows.
 Mostly used directly for printing reports and so forth.
 ExecuteNonQuery: Executes a command that changes the data in the database, such as an
update, delete, or insert .
 This method returns an integer that is the number of rows affected by the query.
 ExecuteScalar: This method only returns a single value.
 This kind of query returns a count of rows or a calculated value.

String com=“Select * from tblStd”;


Sqlcommand comm=new sqlcommand(com,conn);
comm.executenonquery();
ADO. Net DataAdapter Class
3. Data Adapter
The DataAdapter is used to connect DataSets to databases.
Data is transferred to and from a database through a data adapter.
It retrieves data from a database into a dataset and updates the database.
When changes are made to the dataset, the changes in the database are actually
done by the data adapter.

Sqldataadapter da=new sqldataadapter(comm);


ADO. Net DataSet Class
4. DataSet
DataSet is an in-memory representation of data.
When a connection is established with the database, the data adapter creates a
dataset and stores data in it.

 Syntax:
Dataset ds=new dataset(da);
da.fill(ds);
Any Question..?

You might also like