By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,831 Members | 1,031 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,831 IT Pros & Developers. It's quick & easy.

Converting DataReader to a DataTable Performance issue

P: n/a
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!

Sep 7 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Varangian,
Beats me. If it ain't broke, why fix it?
Peter

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


"Varangian" wrote:
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!

Sep 7 '06 #2

P: n/a
what do you mean ?
Peter wrote:
Varangian,
Beats me. If it ain't broke, why fix it?
Peter

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


"Varangian" wrote:
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!
Sep 7 '06 #3

P: n/a
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.

"Varangian" <of****@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
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!

Sep 7 '06 #4

P: n/a
What I meant was, you are correct that the DataAdapter already does this
internally, and it works just fine. In the big scheme of things, the time
difference is inconsequential.
Peter

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


"Varangian" wrote:
what do you mean ?
Peter wrote:
Varangian,
Beats me. If it ain't broke, why fix it?
Peter

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


"Varangian" wrote:
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!
>
>

Sep 7 '06 #5

P: n/a
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
Peter Bromberg [ C# MVP ] wrote:
What I meant was, you are correct that the DataAdapter already does this
internally, and it works just fine. In the big scheme of things, the time
difference is inconsequential.
Peter

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


"Varangian" wrote:
what do you mean ?
Peter wrote:
Varangian,
Beats me. If it ain't broke, why fix it?
Peter
>
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
>
>
>
>
"Varangian" wrote:
>
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!
Sep 7 '06 #6

P: n/a
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


"Varangian" wrote:
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
Peter Bromberg [ C# MVP ] wrote:
What I meant was, you are correct that the DataAdapter already does this
internally, and it works just fine. In the big scheme of things, the time
difference is inconsequential.
Peter

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


"Varangian" wrote:
what do you mean ?
>
>
Peter wrote:
Varangian,
Beats me. If it ain't broke, why fix it?
Peter

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




"Varangian" wrote:

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!
>
>
>
>

Sep 8 '06 #7

P: n/a
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 :)
Peter wrote:
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


"Varangian" wrote:
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
Peter Bromberg [ C# MVP ] wrote:
What I meant was, you are correct that the DataAdapter already does this
internally, and it works just fine. In the big scheme of things, the time
difference is inconsequential.
Peter
>
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
>
>
>
>
"Varangian" wrote:
>
what do you mean ?


Peter wrote:
Varangian,
Beats me. If it ain't broke, why fix it?
Peter
>
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
>
>
>
>
"Varangian" wrote:
>
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!


Sep 11 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.