Wednesday, March 17, 2010

What is the difference between datareader and dataadapter.

This is general typical question asked in the interview.

Datareader :
1) Data Reader will read only one record at a time.So memory consumption will be less,it is purely connection oriented it will use connection exclusively when datareader is closed.the memory will be released on the server machine and connection will be used for any other purpose.

2)
Retrieves a forward-only, read-only data stream from a data source.

3) Datareader reads the row by row. One row at a time.

DataAdapter:

1) Bridges the connected classes with the disconnected classes by retrieving data from a data source and filling a (disconnected) DataSet. The DataAdapter also updates the data source with changes made to a disconnected DataSet. The DataAdapter uses the Connection object to connect the data source and up to four Command objects to retrieve data from and resolve changes (i.e., update, insert, and delete rows) to the data source. The DataAdapter object is specific to the type of data source—for example, the .NET Framework data provider for SQL Server includes the SqlDataAdapter object.

No comments:

Post a Comment