Converting DataReader to a DataTable Performance issue

V

Varangian

Hi all,

the question I want to ask if the conversion of a DataReader to a Table
looping through the DataReader is better than using the Fill Method of
the DataAdapter... I'm asking because internally the DataAdapter uses
the DataReader... so whats the deal of writing a method that converts a
DataReader into a DataTable ?

Thanks!
 
M

Mel

Why don't you make two test functions and time it using TimeSpan. It
really does depend on the size of the database, location of database, number
of records requested and numerous other things.
 
V

Varangian

well its always better in making it faster

DataAdapter are always slow compared to the DataReader

I made a test with about 8000 records first with the DataAdapter and
then the DataReader (building a table), on how long it took on each..
each round representing TotalMilliseconds for a TimeSpan from Start of
execution till End

DataAdapter
1) 701
2) 801
3) 741

DataReader
1) 831
2) 791
3) 871

there seems to be a minor difference ..though I found with my test (is
thsi correct?) that the DataAdapter is faster than the DataReader
(minimal ok)

thanks anyway
 
G

Guest

Well! Thanks for confirming my theme that "if it ain't broke, don't fix it.".
There could also be inconsistencies in your test code, which you didn't
post. But the point is, why get hung up over 1/10 of a second (unless it's
something you are doing 100,000 times in a row...)
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 
V

Varangian

What possible issues did I miss in this test? I just looped through the
datareader and build a row for each record in the DataTable ..

yes I agree with your point.. but in some situations.. its better
winning that 1 second :)
 

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

Top