Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 389
  • Last Modified:

How to move to the First Record of DataSet

How do I move to the first row in a DataSet?

For Each row In DataSet1.Tables(0).Rows
            . . . .
            DataSet1.Tables(0).Rows.Add(row1)
            DataSet1.AcceptChanges()
            . . . .
>>>> need to move to the next row here . .  

Next
0
MikeMCSD
Asked:
MikeMCSD
1 Solution
 
iboutchkineCommented:
Private Sub btnReadDS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReadDS.Click
        'read the whole dataset
        Dim iRow As Integer
        Dim iCol As Integer
        Dim sRowValue As String

        For iRow = 0 To ds.Tables(0).Rows.Count - 1
            For iCol = 0 To ds.Tables(0).Columns.Count - 1
                sRowValue &= ds.Tables(0).Columns(iCol).ToString() & ": " & ds.Tables(0).Rows(iRow).Item(iCol) & " "
            Next
            sRowValue &= vbCrLf
        Next
        MsgBox(sRowValue)
End Sub


basically if you want o read the first row value it will be
ds.Tables(0).Rows(0).Item(iCol)
0
 
MikeMCSDAuthor Commented:
thanks for that . . .
I made a mistake:
>>>> need to move to the next row here . .  
should have been:
>>>> need to move to the FIRST row here . .  

I need to move to the first row of the dataset before the "Next" . .

After the row is added, I get this error:
"collection modified . . enumeration my not operate" . .
so I need to move to the first record, I guess . .
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now