473,326 Members | 2,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Converting DataReader to a DataTable Performance issue

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
7 3366
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Yasutaka Ito | last post by:
Hi, My friend had a little confusion about the working of DataReader after reading an article from MSDN. Following is a message from him... <!-- Message starts --> I was going thru DataReader...
1
by: Rob via .NET 247 | last post by:
Ok, I'm new to .NET so I'm afraid I'm doing something stupidhere, but I'm trying to populate a DataSet manually from aDataReader, and its turning out to be ridiculously difficult. Yes, I could use...
14
by: Bihn | last post by:
I was reading about datareader which is said to be slimmer & faster then dataset. Since the datareader have to go fetching the dat from the database every time it need it, the data it gets then...
3
by: Tim::.. | last post by:
Can anyone tell me how to achieve the following... I want to convert data from a DataReader into a DataTable... I was told this should do it but it doesn't seem to work! Dim Myconn As New...
5
by: jjmraz | last post by:
Hi, I have a situation where in a dll a SqlDataReader is created on a function call but is never closed. The datareader gets passed back to the asp.net page calling it. How should I close the...
7
by: Diffident | last post by:
Hello All, I would like to use DataReader based accessing in my Data Access Layer (DAL). What is considered to be a best practice while returning from a DAL method that executes a query and...
2
by: carlo.gherarducci | last post by:
Hi all, I'm a newbie in .net xml programming, so please be patient. And sorry for my uncorrect english, too. I'm going to explain my problem: I've built a web service which responds to ferries...
6
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I should know the answer to this but i guess i have to ask: Is there a way to reset a data reader to the begining? I figure it's a no, but want to be sure -- thanks (as always) some day i''m gona...
3
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm trying to add a datagridview control to a Windows Form to display read-only information in visual basic 2005. My understanding is that datareader will be faster for this purpose. I have the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.