DataSet vs DataReader

2011-08-10


DataSet is an in-memory representation of a database, providing a consistent relational programming model no matter what format of data source. It contains multiple data tables and their relationship and constraints information.

DataSet works on ADO.NET disconnected mode;

DataReader is a read only, forward only stream of data from a database,  Data are returned as the query executes, and are stored in the network buffer on the client until you request them using the Read method of the DataReader.

Using the DataReader can increase application performance both by retrieving data as soon as it is available, rather than waiting for the entire results of the query to be returned, and (by default) storing only one row at a time in memory, reducing system overhead. – from MSDN

That means DataReader is much faster than DataSet.

DataReader works on ADO.NET connected mode, it needs a connection keeping open.