Getting Data from a DataSet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have a DataSet that was returned from a QueryMethod ( ).

Using the following code, I drilled down to the column level but am unsure
how to get at the data:

Dim ds As System.Data.DataSet
Dim dt As System.Data.DataTable
Dim dr As System.Data.DataRow
Dim dc As System.Data.DataColumn

ds = QueryMethod()

For Each dt In ds.Tables
For Each dr In dt.Rows
For Each dc In dt.Columns
if dr(dc) = "owner" then

' GET DATA VALUE IN THE TABLE IN THE ROW OF THE COLUMN

end if
Next dc
Next dr
Next dt

Thanks for any help.
glenn
 
Ah Glenn, there are million examples of this on the web and in any (growing)
number of books on ADO.NET
once you have the ds:
dim x as Object
x = ds.Tables("Mytable").Rows(0).Item("MyColumnName")
While this will do the trick, it's not (at all) efficient as many have
pointed out. I suggest doing some reading. My book might be a good place to
start...

--
William (Bill) Vaughn
President and Founder Beta V Corporation
Redmond, WA
(425) 556-9205
Microsoft MVP, Author, Mentor
Microsoft MVP
 
and what book name might that be?

William (Bill) Vaughn said:
Ah Glenn, there are million examples of this on the web and in any (growing)
number of books on ADO.NET
once you have the ds:
dim x as Object
x = ds.Tables("Mytable").Rows(0).Item("MyColumnName")
While this will do the trick, it's not (at all) efficient as many have
pointed out. I suggest doing some reading. My book might be a good place to
start...

--
William (Bill) Vaughn
President and Founder Beta V Corporation
Redmond, WA
(425) 556-9205
Microsoft MVP, Author, Mentor
Microsoft MVP
 
See www.betav.com for a complete list. I was referring to either the latest
Hitchhiker's Guide or the "ADO and ADO.NET Examples..." titles. I'm working
on a new version of the HHG for the 2005 products. It should be ready in a
few months.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top