Difference between SqlDataAdapter or sqlDataReader ?


 More Details :  Live Training in jaipur

Ques.1 :  Difference between SqlDataAdapter or sqlDataReader ?
Ans  :      1.A DataReader works in a connected environment,
               whereas DataSet works in a disconnected environment.
               2.A DataSet represents an in-memory cache of data consisting of any number of inter related            DataTable objects. A DataTable object represents a tabular block of in-memory data.

DataReader – The datareader is a forward-only, readonly stream of data from the database. This makes the datareader a very efficient means for retrieving data, as only one record is brought into memory at a time. The disadvantage: A connection object can only contain one datareader at a time, so we must explicitly close the datareader when we are done with it. This will free the connection for other uses. The data adapter objects will manage opening and closing a connection for the
command to execute 

DataAdapter – Represents a set of SQL commands and a database connection that are used to fill the DataSet and update the data source. It serves as a bridge between a DataSet and a data source for retrieving and saving data. The DataAdapter provides this bridge by mapping Fill, which changes the data in the DataSet to match the data in the data source, and Update, which changes the data in the data source to match the data in the DataSet. By using it, DataAdapter also automatically opens and closes the connection as and when required.
go to more help : Web Solution In jaipur

3 comments: