This may help
I have done something like that two different ways:
Both ways loop through a grid bound to the SQL dataset,
that way I can filter the grid to get only the records needed.
The first way stores a record ID in a temporary Table(TempGage) and binds a Grid to the table.
Public TempGage As DataTable
'Loop through Grid and store ID Value
GageGrid.Row = 0
Dim c As Integer = GageGrid.VisibleRows
Dim i As Integer
TempGage = New DataTable("TempGage")
Dim TestRow1 As DataRow
Dim GageId As DataColumn = New DataColumn("GageId")
GageId.DataType = System.Type.GetType("System.String")
TempGage.Columns.Add(GageId)
For i = 1 To c
Try
TestRow1 = TempGage.NewRow()
TestRow1.Item("GageId") = GageGrid.Columns("Gage ID").Value
TempGage.Rows.Add(TestRow1)
Catch ex As Exception
'do nothing
End Try
GageGrid.Row += 1
Next
TempGrid.DataSource = TempGage
The second way adds lines to a checklistbox(clbOperations) control from a Table(tblSF) combining 2 fields into one string.
Dim counter As Integer
Dim OpNumberandName As String
clbOperations.Items.Clear()
OpCounter = 0
For counter = 0 To Me.BindingContext(DsInspFormsShopFloor1, "Shop Floor").Count - 1
Dim tblSF As DataTable
tblSF = DsInspFormsShopFloor1.Tables("Shop Floor")
Dim drCurrentSF As DataRow
drCurrentSF = tblSF.Rows(counter)
OpNumberandName = drCurrentSF("Operation Number") & " " & drCurrentSF("Description")
clbOperations.Items.Add(OpNumberandName)
OpCounter += 1
Next
Hope one of these examples will help.