Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping through DataSet

Status
Not open for further replies.

ninelgorb

Programmer
Mar 7, 2005
111
US
I seem to have completely blanked on this one:

How do I loop through a dataset that came back from a stored procedure?

Thanks...
 
Lookup the DataReader object. Good Luck!

Have a great day!

j2consulting@yahoo.com
 
Code:
dim dr as datarow
for each dr in YourDataSet.tables(0).rows
  debug.writeline dr("FieldName").tostring
next

or

Code:
dim i as integer
for i = 0 to YourDataSet.tables(0).rows.count-1
  debug.writeline YourDataSet.Tables(0).Rows(i).item("FieldName").tostring
next

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
I think you are pulling data out of a particular "fieldname".
WHat if I want to response.write all rows (all the data) of the dataset?
 
If you want to response.write anything, you should try the ASP.Net forum. VB.Net doesn't have a response object so far as I know. ;)

If you are trying to display all of the data, you can loop through all of the columns/items in the row, or you can use a data grid.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Rick--

Code:
dim dr as datarow
for each dr in YourDataSet.tables(0).rows
  debug.writeline dr("FieldName").tostring
next

is old school...

Code:
for each dr as datarow in YourDataSet.tables(0).rows
  debug.writeline dr("FieldName").tostring
next

is 2003 style
 
<for each dr as datarow in YourDataSet.tables(0).rows
Oo, I like that. VB6 is inelegant by comparison.
 
I know...I had heard you say that before. I am normally slow to catch on to syntax changes...but managed to start using that one for some reason. It took me a bit long to use ControlChars.CrLf over VbCrLf for some reason.
 
You're right E&F, I'm like RG though, took long enough to move to controlchars. I like the inline defs for loops, nice an C++ like.

I'm still hoping I can get them to upgrade, I pushed for the CR XI upgrade from CR 9 (we were in a license violation!) but the transition is going horrendously.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top