i m using sql server 2000 with vb 6. i m having some problem in navigating recors..
when i m pressing Move Next,it moves only one record, and when i m moving Move previous, samely it move one previous record...
here is a code...
Option Explicit
Private con As New ADODB.connection
Public rs As New ADODB.Recordset
Private Sub MyDatacon()
If con.State = 1 Then con.Close
con.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ISIS_157;Data Source=JASEEMAHMED"
con.Open
End Sub
Private Sub cmdnext_Click()
Call MyDatacon
Set rs = New ADODB.Recordset
rs.Open "SELECT * FRom ORGANIZATION", con, adOpenStatic, adLockOptimistic
If rs.EOF Then
MsgBox "Last Record"
Exit Sub
Else
rs.MoveNext
Text1.Text = rs!Orgcode
Text2.Text = rs!Organizationname
Text3.Text = rs!Shortname
rs.Update
rs.Close
con.Close
End If
End Sub
Private Sub Comdpre_Click()
Call MyDatacon
Set rs = New ADODB.Recordset
rs.Open "SELECT * FRom ORGANIZATION", con, adOpenStatic, adLockOptimistic
If rs.BOF Then
MsgBox "first Record"
Exit Sub
Else
rs.MovePrevious
Text1.Text = rs!Orgcode
Text2.Text = rs!Organizationname
Text3.Text = rs!Shortname
rs.Update
rs.Close
con.Close
End If
End Sub
Private Sub Form_Load()
Call MyDatacon
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Set rs = New ADODB.Recordset
rs.Open "SELECT * From ORGANIZATION", con, adOpenStatic, adLockOptimistic
rs.MoveFirst
Text1.Text = rs!Orgcode
Text2.Text = rs!Organizationname
Text3.Text = rs!Shortname
rs.Update
rs.Close
con.Close
End Sub