What is sequence of code in retrieving data from database ?

Answer Posted / manoj batra

If using DataSet :
1) Create a connection object
2) Create a DataAdapter object
3) Associate your query and connection with DataAdapter
4) Create DataSet object
5) Fill the dataset with desired result using Fill method of
DataAdapter.
6) start retriving the data into your container from dataset.
Note : DataAdapter automatically Open and Close the connection.

If using DataReader:
1) Create connection object
2) Oen connection
3) Create Command object
4) Create DataReader object
5) Associate your Sql command with the command object
6) Use ExecuteDataReader method inside the loop (The
selective Sql query may return more than one Row)
Note : DataReader is Readonly and ForwardOnly operation.
7) Return result in control(s).
8) Close the connection

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

describe the dataset object in ado.net.

528


Explian About DataAdapters

594


What is ado.net objects?

529


Is it possible to load multiple tables in a Dataset?

538


What is datasource in ado.net?

593






What is an ado connection?

533


What is an ado?

533


What are the different layers of ado.net?

524


Define data access layer?

537


Why do we use sqldataadapter?

487


What is serialization and de-serialization in .net?

504


Where is adodb dll located?

532


Explain the two fundamental objects in ado.net?

511


Which ado.net object is very fast in getting data from the database?

657


What is ole in vb?

518