473,403 Members | 2,323 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,403 software developers and data experts.

Populating a DataSet from a DataReader

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

Similar topics

1
by: Steve | last post by:
C# How do I populate a row in a dataset ? I have created a class called Job. In this class I have a few methods such as CreateJob and FetchJob. FetchJob returns a DataSet of the Job table. The...
3
by: jayfischer91 | last post by:
The method below belongs to a class. The method accepts a dropdownlist as a parameter. Is there any disadvantage to passing in the control and having this method populate it as opposed to passing...
2
by: Janus | last post by:
Hello. I need a little advice for populating the treeview control. I dont want my application to hang while populating the treeview, there is a lot of data what's the best approach? Maybe...
2
by: Ricardo Luceac | last post by:
HI all.. I have a huge table that I want to display in a datagrid, the problem is that if I make a dataset, the entire table must go to the dataset to the data begin to display, and it takes...
4
by: sck10 | last post by:
Hello, I have two dropdown objects that I want to use the same datasource for each. I tried the following, but it doesn't populate the second dropdown. Do I need to close the OleDbDataReader...
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...
2
by: Patreek | last post by:
Hi, I'm writing my first real asp.net app at my job, and I'd like opinions please. In my classic ASP apps that I've written, I'd often have separate files for retreiving data and returning the...
1
by: Dave Hutchings | last post by:
Hi, My problem is this, I have a search screen which creates a query that performs a search on a large database. The results of this search could, if the user requires, return many many rows...
2
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
We have many many systems (accounts) which we need to search on. What my initial Idea is to have a ComboBox1 populated w/ a list of all systems at load (from Oracle table). Done and quick But,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.