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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop through dataset

Status
Not open for further replies.

adugenet

Technical User
Joined
Feb 24, 2007
Messages
48
Location
US
I am using the below code to loop through all the records in a datareader and I am just wondering if someone has done the samething using dataset....I really appreciate if you show me how i can do this for dataset

drc2 = CSVItems.ExecuteReader()


'for field name
For i = 0 To drc2.FieldCount - 1
If i < (drc2.FieldCount - 1) Then
sb.Append(Chr(34) & drc2.GetName(i) & Chr(34) & ",")
Else
sb.Append(Chr(34) & drc2.GetName(i) & Chr(34) & vbCrLf)
End If
Next

'for field value
While drc2.Read()
For i = 0 To drc2.FieldCount - 1
If i < (drc2.FieldCount - 1) Then
sb.Append(Chr(34) & drc2.GetValue(i).ToString.Replace(Chr(34), Chr(34) & Chr(34)) & Chr(34) & ",")
Else
sb.Append(Chr(34) & drc2.GetValue(i).ToString & Chr(34) & vbCrLf)
End If
Next
End While
 
A DataSet is really just a collection of DataTables so you can use the second example from faq855-5662 and just use the first table in your DataSet.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top