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

How to find the given query is optimised one or not?

502


What are the several execute methods of ado.net?

493


If a table contains 20000 records . In a page at each time 100 records to be displayed what are the steps you will take to improve performance? Will you use dataset or datareader?

611


What is the difference between statement and preparedstatement interface?

561


How to check if a datareader is closed or opened? IsClosed()

573






What is the full form of ado?

507


What are the methods of XML dataset object?

611


What are the advantage of ado.net?

515


What is the return type of executescalar?

489


What are all the classes that are available in System.Data Namespace?

548


What do you mean by ‘batch updates’?

508


Explain the architecture of ado.net?

535


What connected data?

491


What is the difference between data grid and data repeater?

500


Is it possible to edit data in Repeater control?

525