473,732 Members | 2,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GETTING DATA FROM A DataSet ??

Can anyone tell me how to pull data from a dataset?

In my Page_Load function, I use the following code:

Dim str As String
Dim ds As System.Data.Dat aSet
Dim dt As System.Data.Dat aTable
Dim dr As System.Data.Dat aRow
Dim dc As System.Data.Dat aColumn

ds = UserTypeQueryMe thod()

For Each dt In ds.Tables
For Each dr In dt.Rows
For Each dc In dt.Columns
if dr(dc) = "owner" then
msgbox(dc.Defau ltValue.ToStrin g())
if dc.DataType <> DBNull then
'GET THE VALUE OF THE COLUMN IN A ROW IN A
TABLE
end if
end if
Next dc
Next dr
Next dt
Mar 21 '06 #1
3 3916
ds.Tables(0).Ro ws(0)(0) ' <--- Somethin' Like that.

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.ma.../13/63199.aspx
----------------------------------------------------------------------------

"glenn" <gl***@discussi ons.microsoft.c om> wrote in message
news:E0******** *************** ***********@mic rosoft.com...
Can anyone tell me how to pull data from a dataset?

In my Page_Load function, I use the following code:

Dim str As String
Dim ds As System.Data.Dat aSet
Dim dt As System.Data.Dat aTable
Dim dr As System.Data.Dat aRow
Dim dc As System.Data.Dat aColumn

ds = UserTypeQueryMe thod()

For Each dt In ds.Tables
For Each dr In dt.Rows
For Each dc In dt.Columns
if dr(dc) = "owner" then
msgbox(dc.Defau ltValue.ToStrin g())
if dc.DataType <> DBNull then
'GET THE VALUE OF THE COLUMN IN A ROW IN
A
TABLE
end if
end if
Next dc
Next dr
Next dt

Mar 21 '06 #2
You are trying to treat a DataSet, as one used to treat ADODB.RecordSet s.

This isn't good practice.

I'd look into the concept of "strongly typed" datasets. you can google that
and find alot of info.

If you don't want to use strongly typed datasets...then I think the issue is
the Column. I don't think this is the info itself, but rather the metadata
about the columns.
Aka, the EmpID, LastName, FirstName

and not the
123,Smith,John
234,Jones,Mary

...


"glenn" <gl***@discussi ons.microsoft.c om> wrote in message
news:E0******** *************** ***********@mic rosoft.com...
Can anyone tell me how to pull data from a dataset?

In my Page_Load function, I use the following code:

Dim str As String
Dim ds As System.Data.Dat aSet
Dim dt As System.Data.Dat aTable
Dim dr As System.Data.Dat aRow
Dim dc As System.Data.Dat aColumn

ds = UserTypeQueryMe thod()

For Each dt In ds.Tables
For Each dr In dt.Rows
For Each dc In dt.Columns
if dr(dc) = "owner" then
msgbox(dc.Defau ltValue.ToStrin g())
if dc.DataType <> DBNull then
'GET THE VALUE OF THE COLUMN IN A ROW IN A TABLE
end if
end if
Next dc
Next dr
Next dt

Mar 21 '06 #3
Your code basically loops through each DataTable in the DataSet and get the
value of each "cell" if that "cell" is not null ---> You are pulling data
from the dataset already... :) Declare this varibale along with the others:
Dim dataPulledFromD S As String = ""
Then in the for loops, right upder the line "'GET THE VALUE OF THE COLUMN IN
A ROW IN A TABLE" put in
dataPulledFromD S = CStr(ds.Tables( dt).Rows(dr).It em(dc))
MsgBox(dataPull edFromDS)

Hope this helps,
VHD50.

"glenn" wrote:
Can anyone tell me how to pull data from a dataset?

In my Page_Load function, I use the following code:

Dim str As String
Dim ds As System.Data.Dat aSet
Dim dt As System.Data.Dat aTable
Dim dr As System.Data.Dat aRow
Dim dc As System.Data.Dat aColumn

ds = UserTypeQueryMe thod()

For Each dt In ds.Tables
For Each dr In dt.Rows
For Each dc In dt.Columns
if dr(dc) = "owner" then
msgbox(dc.Defau ltValue.ToStrin g())
if dc.DataType <> DBNull then
'GET THE VALUE OF THE COLUMN IN A ROW IN A
TABLE
end if
end if
Next dc
Next dr
Next dt

Mar 22 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2846
by: Filippo Pandiani | last post by:
I have a grid that shows the file list from a folder. On the postback, how do I get a Dataset from this grid? Thanks, Filippo.
1
3913
by: Oleg Shnayderman | last post by:
Hi All, I am very new to C# as well as to SQL. I need to write an application which is connecting to SQL DB and getting all the user's tables and after create a dataset for all the tables in the database and create an XML document with all the info. The problem is, that I can do this if I know the table name. However, what if I don't know the table name nor I know how many user's tables in the particular database.
6
3190
by: Erik H. | last post by:
Trying to connect to MySQL db on localhost, and populate datagrid from a dataset using code inline method. Getting the following compile error: Error Message: "CS0246: The type or namespace name 'CoreLab' could not be found (are you missing a using directive or an assembly reference?)" I downloaded the add on for connecting to MySQL using ADO.NET and installed it, but am still getting this error. Anybody ever run into this before?
1
1413
by: Nathan Sokalski | last post by:
I have retrieved data from a database using a SELECT statement that includes an INNER JOIN. The data seems to be retrieved to the DataSet OK, but I am having trouble getting the data from the DataSet. The code I am using is as follows: Private Sub btnDownloadDB_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnDownloadDB.Click Dim papdatabase As New DataSet Dim cmdSelect As New...
4
3886
by: What-a-Tool | last post by:
I am trying to write a program that will take all the members of a data base, add them to a tree, with all child relations as sub-nodes. I am having a problem getting the parent child relations for each table & query. Dim tblCurrent As DataTable Dim strTableName As string For Each tblCurrent In Ds1.Tables
13
10141
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the parent table. ----------------------------
0
4556
by: mike1402 | last post by:
Hi ! I get the error below sometimes when retrieving a big amount of data using Datadapter.Fill(dataset,"table"). But when I send the command Fill again, there is no error. Is it a fault of IBM.Data.DB2.iSeries; Version: v1.0.3705 (is there an newer one for OS/400 Version ist V5R3 ?) or is it a hardware faoult (memory of as400 or pc) ? br mike Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein...
3
2649
by: H | last post by:
I have a dataset with Customers, Orders, and Items tables. It has datarelations set between Customers-Orders and Orders-Items It has foreignkeyconstraints with update/delete rules set to cascade for Orders & Items. The dataset is filled with Customers and their related Orders and their related Items. What is the most efficient way to create a second dataset that is a subset of the main dataset, but only has data for Customer_id = "1"
4
1480
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Why am I getting an error when I passed by ref a dataset to a new form? The message reads "cannot convert from 'ref Paimport.unixAccount' to 'ref System.Data.DataSet'. Paimport is the name of the form where the dataset UnixAccount is created. I created the dataset using the designer tool and not by code. So it's like a type or class which I then declare an instance of it : UnixAccoutns dsAccounts = new UnixAccoutns (); I pass to a new...
2
1888
by: rocketfire97 | last post by:
I'm trying to call a COM object using C# but having no luck getting values back for passed in ref objects. I've tried the same call using VB.NET and can get data back. How would I implement the following in C# This is the method I am calling, which populates ref paramters with results. Sub Check_Customer(ByVal Customer As String, Optional ByRef oParam1 As
0
8774
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9447
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...
0
9307
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9235
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
8186
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
6031
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
4550
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
3261
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
2721
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.