How to convert SqlDatareader to DataTable
Hello all,
Is there a way to convert a SqlDatareader to DataTable?
I'm not talking about looping through the datareader and add each value into the datatable. For example the dataset, you use a DataAdapter to fill the data into the dataset.
I've read on something like a ovrride the fill function and of the DbDataAdapter ... but it doesn't seem to work ...
protected overridable function(dataTable as DataTable, dataReader as IDataReader) as integer
return Fill(dataTable, dataReader)
end function
Has anyone done this before? Any input is appreciated.
Unfortunately, as far as I know, the answer is no - due to the inherent nature of a DataReader itself. It's a forward only/read once process. If you don't do something with it at the time it's being created, it's gone.
The only way I can think of to take care of that, would be to manually insert the objects into the datatable, as the datareader was being read
David, your icon is scary ... lol. thanks for the respond. please take a peek at this URL:http://msdn2.microsoft.com/en-us/library/497b1k4t.aspx
and also this sample:http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=628
I tried but somehow I can't get it to run. Well, I didn't copy all of the author's code. What do you think?
Labels: ado, convert, datareader, datatable, datatableim, looping, net, sqldatareader, value
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home