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
How many major types of connection objects in ADO.NET?
What is typed dataset ?
What are typed and untyped dataset?
What is the usage of the dataset object in ado.net?
Explain the role of data provider in ado.net? What is the role of data provider in ado.net?
Give few examples of datareader that is used in different dataproviders.
What is the use of Dataview?
What is the role of data provider in ado.net?
What is row state?
Define different execute methods of ADO.NET command object ?
What are the namespaces used in ADO.Net to connect to a database?
What is connection string?
What is concurrency? How will you avoid concurrency when dealing with dataset? (One user deleted one row after that another user through his dataset was trying to update same row. What will happen? How will you avoid the problem?)
What are the key events of sqlconnection class?
What is namespace in ado.net?