DataReader. From a network point of view, I'm curious as to which way
would perform better and be less problematic for the network. I won't
have any control on the amount of data that comes back...it could vary
each time.
When you fill a DataTable/DataSet (which is a collection of DataTables plus
much more), the DataTable internally uses a DataReader to populate its rows.
So in terms of what would be more/less problematic, wouldn't be whether
using a DataReader is better than using a DataTable/DataSet... but rather
your use of the resource.
If you are iterating through 10,000 rows of a DataReader, and do any more
than just populating an internal collection/representation of that data,
such as processing financial statistics or something like that, then you are
actually consuming more processing time with an open connection to the
server than if you just iterate and populate and close (exactly what a
DataSet/DataTable does internally). So in each iteration of the Reader
you'll want to do as little processing as possible before you get the next
row and work with that otherwise you're in danger of over-consuming the
server resources (could be a problem in a high-volume transaction
environment where there are many users such as a web application or web
server or something).
Thanks,
Shawn