You are on page 1of 3

ADO.NET will depend only on two components.

1. Data Provider :
Providing the connections
Executing the sql commands within database
Fetching sql command results and forwarding to client applications.
Fill that fetched data to local database.

Supports 4 objects
1. Connection object : open, maintain and close connection
Using system.data.sqlclient

Sqlconnection con = new sqlconnection();


con.open()
con.close()

2. Command object : dml operations in central database.


Sqlcommand cmd = new Sqlcommand()

3. Datareader object : we can bind sql command result data and bind to the client application.
Only used in connection oriented.
Sqldatareader dr = cmd.ExecuteReader();

4. Dataadapter object :
Fetch the data from central db and forward to the client, local db
Sqldataadapter da = new Sqldataadapter();

2. Data Set :
Import using system.data;

Data set is nothing but local database

Used in disconnected architecture

Dataset ds = new dataset();

Required to implement connection oriented :

Fetch the data from database and displayed to user.

Data Provider :

Connection object

Command object
Dataadapter object

Steps :

1. Importing data provider


Using system.data.client;

2. Defining connection string


String cs = “server = ; database = ; uid = ; pwd = ”;

3. Creating connection onject


Sqlconnection con = new sqlconnection();
con.open()

4. Defining command object


Sqlcommand cmd = new Sqlcommand(“select * from emp”, con);

5. Defining dataadapter
Sqldatareader dr = cmd.executereader();

6. Binding the data datareader object to client application

7. Con.close()

Required to implement connection oriented :

Fetch the data from database and DML operations.

Data Provider :

Connection object

Command object

Dataadapter object

Data Set

Steps :

1. Importing data provider


Using system.data.client;

2. Defining connection string


String cs = “server = ; database = ; uid = ; pwd = ”;
3. Creating connection object
Sqlconnection con = new sqlconnection();
con.open()

4. Defining command object


Sqlcommand cmd = new Sqlcommand(“select * from emp”, con);

5. Defining dataadapter
Sqldataadapter da = new Sqldataadapter();

6. Getting local database


Dataset ds = new dataset();

7. Filling the fetched data from central database to local database.


da.fill(ds,”emp_new”);

8. Con.close()

9. We can do dml operations to local database.

You might also like