I'm trying to find a record and then move up or down in .net what I have so far is :
This code returns the correct record but seems like there should be a better/different way to find one (1) record than looping.
Then next part of moving up or down is puzzling to me in .net since movenext/moveprevious does not seem to exist in.net.
Any ideas are greatly appreciated. Thank you.
Code:
Public Sub Find(ByVal sLast As String, ByVal sFirst As String, _
ByRef bFound As Boolean, ByRef iID As Integer)
Dim dr As DataRow
Dim rs As adodb.
da = New OleDbDataAdapter()
ds = New DataSet()
sLast = Replace(sLast, "'", "''")
Dim table As New DataTable
cmd = New OleDbCommand("SELECT * FROM Members WHERE Lastname = '" & sLast & "'AND" & _
" Firstname = '" & sFirst & "' AND ID = " & iID, cn)
da.SelectCommand = cmd
da.Fill(ds, "Members")
nMember = New CMember
Try
For Each dr In ds.Tables("Members").Rows
iID = CInt(dr("ID"))
sFirst = CStr(dr("Firstname"))
sLast = CStr(dr("Lastname"))
Next
bFound = True
Catch ex As Exception
MessageBox.Show(ex.Message)
bFound = False
End Try
End Sub
Then next part of moving up or down is puzzling to me in .net since movenext/moveprevious does not seem to exist in.net.
Any ideas are greatly appreciated. Thank you.