what is the difference between data adapter and data reader?
Asked Answered
M

7

11

What is the difference between data adapter and data reader?

Manufacturer answered 16/7, 2009 at 18:13 Comment(0)
H
13

Please see DataReader, DataAdapter & DataSet - When to use? :

ADO.NET provides two central Data Access Components. The excellent thing is that, they are common across all Databases, be it SQL Server or other competitive databases. Its only the namespace to be used, that differs, while using a Database other than SQL Server.

Hausfrau answered 16/7, 2009 at 18:15 Comment(1)
Just presenting a link? Is it not a comment?Blinnie
E
9

A DataReader is an object returned from the ExecuteReader method of a DbCommand object. It is a forward-only cursor over the rows in the each result set. Using a DataReader, you can access each column of the result set, read all rows of the set, and advance to the next result set if there are more than one.

A DataAdapter is an object that contains four DbCommand objects: one each for SELECT, INSERT, DELETE and UPDATE commands. It mediates between these commands and a DataSet though the Fill and Update methods.

Empower answered 16/7, 2009 at 18:16 Comment(0)
J
5

Data Reader is an object used in connected Environment. Data Adapter is an object used in Disconnected environment using Dataset.

Jessen answered 5/3, 2013 at 15:2 Comment(0)
U
4

DataReader is a faster way to retrieve the records from the DB. DataReader reads the column. DataReader demands live connection but DataAdapter needs disconnected approach.

Ula answered 29/3, 2012 at 11:15 Comment(0)
G
4

Here is a nice article on the above topic: Difference Between DataReader, DataSet, DataAdapter and DataTable in C#

Key differences in simple terms:

Unlike classic ADO, which was primarily designed for tightly coupled client/server systems,ADO.NET was built with the disconnected world in mind, using DataSets/DataAdapter.

  • DataAdapter follows connectionless-oriented architecture which simply means you need not necessarily be connected to a data-source whereas DataReader is a connection-oriented architecture which means it needs an active connection to a data-source for it to operate.
  • DataAdapter is an intermediate layer/ middleware which acts a bridge between the DataSet and a Database whereas DataReader provides forward-only, read-only access to data using a server-side cursor (simply put it is ued to read the data).
  • Using DataSet we can manipulate and update a DataSet's contents while disconnected from the Datasource and send any modified data back for processing using a related DataAdapter whereas DataReader can only read data from a Database & cannot modify it.
  • DataAdapter object is used to read the data from database and populates that data to DataSet whereas DataReader simply reads the data using the Read() method.
  • DataAdapter is comparatively slower whereas using DataReader can increase application performance both by retrieving data as soon as it is available, and (by default) storing only one row at a time in memory, reducing system overhead.
Gowen answered 10/11, 2019 at 8:32 Comment(0)
T
2

Data reader is an object through which you can read a sequential stream of data. it's a forward only data wherein you cannot go back to read previous data. data set and data adapter object help us to work in disconnected mode. data set is an in cache memory representation of tables. the data is filled from the data source to the data set thro' the data adapter. once the table in the dataset is modified, the changes are broadcast to the database back thro; the data adapter.

Thoraco answered 5/8, 2010 at 12:2 Comment(0)
D
2

DataAdapter

DataAdapter will acts as a Bridge between DataSet and database. This dataadapter object is used to read the data from database and bind that data to dataset. Dataadapter is a disconnected oriented architecture.

DataReader

DataReader is used to read the data from database and it is a read and forward only connection oriented architecture during fetch the data from database. DataReader will fetch the data very fast when compared with dataset. Generally we will use ExecuteReader object to bind data to datareader

Durgy answered 21/1, 2017 at 8:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.