RowSet.MoveToNextRow

From Xojo Documentation

Method

RowSet.MoveToNextRow()

New in 2019r2

Supported for all project types and targets.

Moves the current row to the next row in the RowSet. After the last row, RowSet.AfterLastRow is True.

Examples

The following method populates a DesktopListBox with a RowSet. It uses the Name and StringValue properties to obtain the column names and values:

Sub PopulateListBox(dataList As DesktopListBox, rs As RowSet)
If rs Is Nil Then Return

// set up listbox state for population
dataList.RemoveAllRows

// Add the DB columns as the headers for the ListBox
dataList.ColumnCount = rs.ColumnCount
dataList.ColumnAttributesAt(-1).WidthExpression = "100"
For i As Integer = 0 To rs.LastColumnIndex
dataList.HeaderAt(i) = rs.ColumnAt(i).Name
Next

// Add the data from the table
While Not rs.AfterLastRow
dataList.AddRow("")

For i As Integer = 0 To rs.LastColumnIndex
dataList.CellTextAt(dataList.LastAddedRowIndex, i) = rs.ColumnAt(i).StringValue
Next

rs.MoveToNextRow
Wend
rs.Close
End Sub