Fastest way to get data?

  • Thread starter Thread starter Code Monkey
  • Start date Start date
C

Code Monkey

DataTable loading a SqlDataReader (dt.Load())?
Vanilla DataTable using SqlDataAdapter
or SqlDataReader ?

or is there a better way using Generics? If so, how? Essentially I
want to get about 50-100 rows of data (2 columns) out of my database
and use this is serveral places without caching it as the data could
get updated several times during a period of 5 minutes and thus, needs
to be always up-to-date.


TIA

Dave
 
DataReader is certainly the "fastest" way to get the data, but you also have
to consider what you are doing with it. If you are holding on to the data
over a period of time with only a DataReader to firehose over, you are
holding a connection open.
Loading into a DataTable may add a couple of milliseconds to the operation
but you can close the connection and allow it to return to the pool, and now
you have your data in a disconnected manner until the next time you need to
get it.
In the big scheme of things, with only 50 to 100 rows, we are talking mere
miliseconds here.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
 
Thought it might be - but there's no harm in asking. Most of my work
involves DataTables anyway.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top