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

Populating a DataSet from a DataReader

P: n/a
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 a DataAdapter to more easily load the DataSet,but that would entail loading a couple of gigs worth of datainto memory at once, which is bound to be bad. So I'm trying touse a DataReader to collect a group of rows, one row at a time,until I have a group which I can process. Then I perform mycalculations, store my results, clear the DataSet, and startcollecting from the DataReader again. But there doesn't seem tobe an easy way to get a row's worth of results from a DataReaderand insert them in a DataSet (that I can find, anyways.) I cameup with a convoluted set of actions involvingDataReader.GetSqlValues and DataRow.ItemValues, but as itdoesn't work I won't bore you with the details. (It doesn'tknow how to convert the elements of the generic object array tothe appropriate types for the DataRow.)

Anybody know how to get a row out of DataReader and into aDataSet?

- rob.

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>FoldYBbDek+OAbPvHqeVvg==</Id>
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
As I mentioned in the performance newsgroup there are new overloads to
DataAdapter.Fill() in CLR 2.0 that may be helpful.

However, it's possible that a DataTable is too general-purpose and
heavy-weight for what you need. Have you considered transferring each
incoming record to a strongly-typed passive container class and then perhaps
creating a collection derived from CollectionBase for those containers? Or
perhaps using an ArrayList of Hashtables? Or even a Hashtable of
Hashtables? If you need to do a lot of navigation by something other than
key value then you may actually need DataTables / DataSets -- but I'm just
probing. If all you are trying to escape is forward-only navigation, there
are other alternatives that may be easier for you to work with.

--Bob

"Rob via .NET 247" <an*******@dotnet247.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Ok, I'm new to .NET so I'm afraid I'm doing something stupid here, but I'm
trying to populate a DataSet manually from a DataReader, and its turning out
to be ridiculously difficult.

Yes, I could use a DataAdapter to more easily load the DataSet, but that
would entail loading a couple of gigs worth of data into memory at once,
which is bound to be bad. So I'm trying to use a DataReader to collect a
group of rows, one row at a time, until I have a group which I can process.
Then I perform my calculations, store my results, clear the DataSet, and
start collecting from the DataReader again. But there doesn't seem to be an
easy way to get a row's worth of results from a DataReader and insert them
in a DataSet (that I can find, anyways.) I came up with a convoluted set of
actions involving DataReader.GetSqlValues and DataRow.ItemValues, but as it
doesn't work I won't bore you with the details. (It doesn't know how to
convert the elements of the generic object array to the appropriate types
for the DataRow.)

Anybody know how to get a row out of DataReader and into a DataSet?

- rob.

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>FoldYBbDek+OAbPvHqeVvg==</Id>
Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.