VB6 used movenext and moveprevious to increment/decrement the absolute record in a dataset. VS 2008 does not seem to have those features.
This is what I have to start. iMemberID finds the current record, next find the total number of rows (iMaxRows), then run through the database looking for the iMemberID to find that row number using the For i, next loop.
Using a known row number from the database of 30 and choosing that record (iMemberID=12), this function does not do what is intended.
Any ideas would be great. thanx.
This is what I have to start. iMemberID finds the current record, next find the total number of rows (iMaxRows), then run through the database looking for the iMemberID to find that row number using the For i, next loop.
Code:
Public Function GetAbsRec(ByVal iMemberID As Integer, ByRef absPos As Integer) As Integer 'iMemberID is current record
Dim rw As DataRow
ds = New DataSet()
da = New OleDb.OleDbDataAdapter
cn.Open()
cmd = New OleDbCommand("SELECT MemberID, Lastname, Firstname FROM Members" & _
" WHERE MemberID=" & iMemberID & _
" ORDER BY Lastname, Firstname", cn) 'Finds the current record (starting point)
da.SelectCommand = cmd
da.Fill(ds, "Members")
da = New OleDbDataAdapter
cmd = New OleDbCommand("SELECT * FROM Members", cn)
da.SelectCommand = cmd
da.Fill(ds, "Members")
iMaxRows = ds.Tables("Members").Rows.Count - 1 'iMaxRows determines # of rows in table
For i = 0 To ds.Tables("Members").Rows.Count - 1
rw = ds.Tables("Members").Rows(i)
If rw.Item("MemberID") = iMemberID Then
abspos = i
End If
Next
If abspos = iMaxRows - 1 Then ' At the end of the table
abspos = 0 'this should be the first record
rw = ds.Tables("Members").Rows(abspos)
iMemberID = rw.Item("MemberID")
End If
cn.Close()
Return absPos
End Function
Using a known row number from the database of 30 and choosing that record (iMemberID=12), this function does not do what is intended.
Any ideas would be great. thanx.