Wednesday, December 27, 2006

using a dataset versus using a datareader

DataSet:
1. used to retreive data in a disconnected manner.
2. can be serialized and transported to another system (using xml)
3. extremely flexible for manipulating data.

DataReader:
1. used to retreive data in a connected manner, until closed.
2. cannot be serilized, and is used only for read scenarios.

Internal functionning of the dataset:
1. it uses a DataReader to retreive its data, and then disconnect.
2. its structure is persisted in memory or using xml.

in this case, it is useless to use the dataset, in order to fill another structure such as a generic list System.Collections.generic.List, System.Collections.generic.List(Of T).

It is better to use a datareader to fill a generic list.

for more information on this:
perfomance check list for ado.net
http://msdn2.microsoft.com/en-us/library/ms998589.aspx
Imporving ADO.NET performance
http://msdn2.microsoft.com/en-us/library/ms998569.aspx



very useful information.
comments welcome,
happy programming!