Getting data from a dataset one field at a time

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

Guest

I have create a dataset that contains only the data that I want. Now I want to display the data a field at a time. How do I retreive the data in order to display it? I have included a code sample below:

Private Sub GetDataByEventType(ByVal AlertType)
Dim AlertTypeData As DataTable = AlertDS.Tables("AlertDetail")
' Check for Alert Type of Speeding as an EventType.
Dim AlertExpression As String
' Dim EventType as String =
'Dim TypeOFAlert As String = AlertType
AlertExpression = "EventType = 'Speeding' and Speed > EventDataLow"
Dim AlertsFound() As DataRow
' Use the Select method to find all rows matching the filter.
AlertsFound = AlertTypeData.Select(AlertExpression)
Dim Alert As Integer
' Send Message to Screen of each returned row.
For Alert = 0 To AlertsFound.GetUpperBound(0)
Console.WriteLine(AlertsFound(Alert)(0))
' MsgBox("Min Number: " & Min_Num & "is Speeding" & "Speed is: " & Speed)
Next Alert
End Sub
 
A DataSet contains a Rows collection. You position to the rows collection
using an ordinal
myRow = ds.Rows(n)
Once positioned to a row, you can extract a Row object and iterate through
the "Items" using an ordinal or by using the Field name.

Dim ds As New DataSet

Dim dr As DataRow

Dim n As Integer

Dim strV As String

dr = ds.Tables(0).Rows(n)

strV = dr.Item(n)

strV = dr(n).ToString

Does this help?


--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
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.
__________________________________

Larry Bird said:
I have create a dataset that contains only the data that I want. Now I
want to display the data a field at a time. How do I retreive the data in
order to display it? I have included a code sample below:
 
Back
Top