Question

Lets say I have a dataset with I dunno 20 records in it.

How do I get to the 16th record in the dataset or the Nth? So any number from 1 to 20

I have spent most of this week trying to think of a method and so far I have gotten no where.

I want the 16th record down in this dataset and there doesn't seem to be a specific command for it.

I'm working in VB.NET with OLE commands.

I'm not sure any code would be of any use to help solve this but I'm populating the dataset something like this:

SQL_Str = "SELECT FROM A TABLE WHERE CRITERIA IS MET"
dbDataAdapter = New OleDbDataAdapter(SQL_Str, dbConnector)
dbDataAdapter.Fill(DataSet, "SelectedRecords")

Now what do I do to get to the 16th row in this dataset knowing that there is 20 records in the dataset?

Was it helpful?

Solution

Since you say you are using VB.NET, just read the row from the dataSet.

Private Function GetRow(ByVal ds As Data.DataSet, ByVal rowNum As Integer) As Data.DataRow
  Dim result As Data.DataRow = Nothing
  Dim table As Data.DataTable = ds.Tables(0)
  result = table.Rows(rowNum)
  Return result
End Function

There are overloads to DataSet.Tables: Consider:

screenshot

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top