473,657 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 involvingDataRe ader.GetSqlValu es and DataRow.ItemVal ues, 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 3126
As I mentioned in the performance newsgroup there are new overloads to
DataAdapter.Fil l() 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*******@dotn et247.com> wrote in message
news:%2******** *******@TK2MSFT NGP09.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.GetS qlValues and DataRow.ItemVal ues, 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
1351
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 idea being, when I want to view or modify a certain Job , I call this method, passing in the unique ID and get back a dataset with that row in it. In the Job class though, how do I populate a row with the relevant info? My first attempt was...
3
1540
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 back a datareader from this method and having the webform populate it? It seems to work great! Just wondering if there may be a disadvantage to passing a control. Oh yea, by the way, it is just passing a pointer to the control, right? Or...
2
2679
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 something eventbased but how? please help... Should I avoid populating the treeview control using a thread?
2
8477
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 much time... I need to start show data after a row pushed to the dataset, so I think of using the datareader to populate a datatable and bind the datatable to the datagrid.
4
1135
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 and then re-open it to populate the second dropdown object? Thanks in advance, sck10
14
2233
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 should be up to date. However, both the IbuySpy and Duwamish samples and most, if not all, the shopping cart sample codes I've seen use dataset to implement the opration for ecommerce sites. So is the trip that the datareader need to go fetch the...
2
1724
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 data to other pages that would call it. I'd return the data as arrays so that I wouldn't have to have my DB connections open all the time while the pages ran. Now in .net, it seems like I have to choose between using a SQldatareader or a...
1
1535
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 (20,000)..... In other languages, when faced with this problem, you can run a query and link it to a datasource and link the datasource to a table. You can then set an option called packetrecords to 20. If your grid has 40 rows, then as it populates...
2
1396
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, step two, I want to populate ComboBox2 depending on the System selection from ComboBox1 . But, the problem is, I can load the list of 'Systems' data into a dataset in just a few seconds. I did a quick test and filled a dataset selecting...
0
8407
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8837
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8512
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8612
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7347
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.