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
What is ambient transaction?
What two types of data providers does ADO.NET supply? What determines which one you should use?
Can we do database operations without using any of the ado.net objects?
What is command class in ado.net?
How to identify the controls which can be used for binding data?
What are the namespaces used in ado.net for data access?
What are the steps you will take to improve performance?
What is Dataset Object?
What does adodb stand for?
Which keyword is used to accept variable number of parameters?
What are the Features and disadvantages of dataset
What is the significance of CommandBehavior.CloseConnection ?
How does entity framework work?
What are the advantages of oledb compared with other classes?
How can you add or remove rows from the datatable object of dataset?