Record Position and Navigation in Datasets (url follows)
Because a dataset is a fully disconnected container for data, datasets (unlike ADO recordsets) do not need or support the concept of a current record. Instead, all records in the dataset are available.
Because there is no current record, there is no specific property that points to a current record and there are no methods or properties for moving from one record to another. (In contrast, ADO recordsets support an absolute record position and methods to move from one record to the next.) You can access individual tables in the dataset as objects; each table exposes a collection of rows. You can treat this like any collection, accessing rows via the collection's index or using collection-specific statements in your programming language.
see:
http://msdn.microsoft.com/library/en...asp?frame=true
'I made my own code:
Public Class DataSetScroll
Private m_dataSet As DataSet = Nothing
Private m_rowCounter As Int32 = -1
Private m_tableName As String = ""
Public ReadOnly Property DataSet() As DataSet
Get
Return m_dataSet
End Get
End Property
Public ReadOnly Property RowNumber() As Int32
Get
Return m_rowCounter
End Get
End Property
Public Sub New(ByRef ds As DataSet, ByVal tableName As String)
m_dataSet = ds
m_tableName = tableName
End Sub
Public Function MoveNext() As Boolean
If m_dataSet.Tables(m_tableName).Rows.Count - 1 <= m_rowCounter Then Return False
'
m_rowCounter += 1
Return True
End Function
Public Function CurrentRow() As DataRow
'row-pointer-counter initialized?
If m_rowCounter = -1 Then
If m_dataSet.Tables(m_tableName).Rows.Count > 0 Then
m_rowCounter = 0
Else
Throw New Exception("Table """ & m_tableName & """ has no rows, it is empty!")
End If
End If
'
Return m_dataSet.Tables(m_tableName).Rows(m_rowCounter)
End Function
Public Function IsEmpty() As Boolean
If m_dataSet.Tables(m_tableName).Rows.Count < 1 Then
Return True '=is empty
Else
Return False '=is NOT empty
End If
End Function
End Class
'and use:
Dim dss As DataSetScroll = a.GetDataSetScroll(scope)
If dss.IsEmpty Then Exit...
Do
dim val as Object = dss.CurrentRow.Item("colName")
Loop Until Not dss.MoveNext