DataSet vs DataReader

wyrd

Well-known member
Joined
Aug 23, 2002
Messages
1,408
Location
California
Sorry if this has been discussed (I looked through the pages real quick and didnt see any topics on it), but here goes...

Is there any place where I can read up on DataSets and DataReaders and the performance related between the two?

Im curious as to when its best to use one over the other, or which situations it probably wouldnt matter. Some seem obvious, such as multiple clients using the same database over a network (DataSets) or you just want to quickly retrieve some records from a database where no updating etc is involved (DataReader). However theres that middle portion for small business type apps where youre only dealing with a few thousand records (and the client is on the same computer as the database). On top of all this, in ASP.NET DataSets are created in memory on the server, which opens a whole new can of worms on when to use which.
 
I purchased the ADO.NET book from Microsoft

ISBN 0-7356-1423-7

and have found it to be an excellent resource, especially in the diffs between sets and readers.

i have not yet found a REALLY good .com resource..i have found pages here and there. the book so far has been best.
 
In addition to the resources above, Ill add that sometimes your task at hand will only allow you a DataSet or a DataReader. For instance, if you want to bind a datagrid youll need a dataset. You could conceivably read in data through a datareader and populate some custom type, even a dataset built from the DataReader, but I would go with a DataSet.

Also, if you want to databind and have simplified updates, youll want a DataSet. A DataReader can only read in data - no updates.

-nerseus
 
In VB6 it was usually considered a bad idea to be binding things all over the place because you didnt have to much control over it all. In VB.NET though, it seems like youre in complete control, although binding a DataSet takes a lot more work then it used to.

As for DataSet vs DataReader, it seems like in ASP.NET its DataReader all the way (unless forced to use a DataSet somehow). In a regular application (just a single db app on a single machine), if youre going to be doing updates and manipulation, it probably doesnt matter much unless youre doing lots of updates and what not or if you want to be binding stuff. For server/client the obvious choice seems to be DataSet.

Just tossing out some thoughts here as Im thinking to myself, so feel free to add your own if you think mine are flawed (they probably are, Im only right 0.001% of the time). Feel free to slap me upside the head too. ;)
 
Back
Top