Monday, March 12, 2012

How to convert a datareader to datatable?

How to convert a datareader to datatable?DataTable.Load?
--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
"abc my vclass" <myabcclass@.myclass.com> wrote in message
news:eu$Ato6AGHA.2544@.TK2MSFTNGP11.phx.gbl...
> How to convert a datareader to datatable?
>
ABC,
In the same way as that you convert an engine to a wheel of a car.
A datareader is a class that is used by the dataadapter to load a datatable.
I hope this gives an idea.
Cor
Check this blog post:
Convert a DataReader into a DataSet
http://weblogs.asp.net/rosherove/archive/2004/01/22/61541.aspx
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"abc my vclass" <myabcclass@.myclass.com> wrote in message
news:eu$Ato6AGHA.2544@.TK2MSFTNGP11.phx.gbl...
> How to convert a datareader to datatable?
>
Teemu,
Why do you think that as written on the blog page that it is a fast
solution. We have almost as long as our website exist this sample on our
website, however I will never tell that it is fast. It is slow, but can be
used if someone wants a progressbar. And than he/she should have a huge
amount of data and accept that it is going a little bit slower.
http://www.vb-tips.com/default.aspx?ID=49f2cff5-56ad-44fc-a4c6-fc0d5c470f53
Just my thougth,
Cor
Cor,
> Why do you think that as written on the blog page that it is a fast
> solution. We have almost as long as our website exist this sample on our
> website, however I will never tell that it is fast.
Did I say something like that? Which one of those few implementations I've
said is fast? There are quite many variations on that blog, if you check
them (comments also) Not sure if I follow your question, though.
> It is slow, but can be used if someone wants a progressbar. And than
> he/she should have a huge amount of data and accept that it is going a
> little bit slower.
> http://www.vb-tips.com/default.aspx?ID=49f2cff5-56ad-44fc-a4c6-fc0d5c470f53
Ah, If you mean which one I'd use, I'd take the one inheriting from
DBDataAdapter or the one using BeginLoadData and LoadDataRow (DBDataAdapter
uses that internally, so the selection goes to scenario preference). Why?
Because using BeginLoadData turns off constraints , index maintaining etc
when loading data.
Regards,
Teemu
Teemu,
> Ah, If you mean which one I'd use, I'd take the one inheriting from
> DBDataAdapter or the one using BeginLoadData and LoadDataRow
> (DBDataAdapter uses that internally, so the selection goes to scenario
> preference). Why? Because using BeginLoadData turns off constraints ,
> index maintaining etc when loading data.
>
I like just the DBDataadapter.
The slight performance that is gained by other solutions, is in my opinion
lost by wors maintainability.
Cor
Like Miha mentions, Datatable.Load works great ifyou're using the 2.0
Framework, but out of curiousity, what is the challenge your wanting to
address by doing this?
"abc my vclass" <myabcclass@.myclass.com> wrote in message
news:eu$Ato6AGHA.2544@.TK2MSFTNGP11.phx.gbl...
> How to convert a datareader to datatable?
>

Labels: , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home