SqlDataReader will be slightly faster than the DataSet when just using them
for data binding, primarily because the DataSet is an extra in-memory copy
of the data. So if your situation is just data binding, then go for the data
reader approach. But this also means you're always going to the data base
for the data. If you're looking to hold onto the data for a longer period
(for caching purposes or for doing extra processing on the data) then that's
when you'd prefer a DataSet. The DataSet also allows you to create additional
columns that are calculated and in conjunction with the DataView you can
easily get sorting and filtering (not that you can't with SQL statements
back in the DB, but the work's offloaded to the webserver).
Anyway, the fact that you're simply aware of the two is a good start. Each
one has its place.
-Brock
DevelopMentor
http://staff.develop.com/ballen I'd like to know when a DataSet is the preferred way to retrieve, and
specifically update/delete, data in an ASP.NET application. I've been
using straight SQL by using the SqlCommand and SqlDataReader objects.
I'd like to know if there is anything wrong with this approach. It
appears that if you want to use a DataSet for an update that you have
to persist it so you can use it in a subsequent postback. That seems
like it might become expensive, but maybe the cost of persisting it is
outweighed by some other optimization that I am not aware of. Any
help would be much appreciated.
Thanks.