Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Navigation buttons

Navigation buttons

Scheduled Pinned Locked Moved Database
databasesql-serversysadmin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ranjita Ghosh
    wrote on last edited by
    #1

    Hi Everybody! I am using VB6.0 & SQL Server 7.0 Following is my database Connection code Dim db As ADODB.Connection Dim rs As ADODB.Recordset Dim sql As String Set db = New ADODB.Connection db.Provider = "SQLOLEDB" db.ConnectionString = "server=SUNANDA;uid=sa;pwd=ranjita1;database=crm" db.Open Set rs = New ADODB.Recordset sql = "Select * from AccountHead" Set rs.ActiveConnection = db rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open sql, , , , adCmdText I have placed navigation buttons on my form, but the Next & Previous buttons are not working properly. When I first time clicks the Next button , the recordset goes to the next record but when I click it second time, the record doesn’t get changed. When I press the previous button, the recordset points to the first record, instead of pointing to the previous record. Here is my code for navigational buttons:^): Public Sub MoveFields() txtAcId.Text = rs("AcHeadID") txtAcName.Text = rs("AcHeadName") txtAcMobile.Text = rs("Mobile") txtAcEmail.Text = rs("EmailID") End Sub Private Sub cmdFirst_Click() rs.MoveFirst MoveFields cmdPrev.Enabled = False cmdNext.Enabled = True End Sub Private Sub cmdLast_Click() rs.MoveLast MoveFields cmdNext.Enabled = False cmdPrev.Enabled = True End Sub Private Sub cmdNext_Click() rs.MoveNext If rs.EOF Then rs.MoveLast cmdNext.Enabled = False End If MoveFields cmdPrev.Enabled = True End Sub Private Sub cmdRemove_Click() rs.Delete rs.MoveNext If rs.EOF Then rs.MoveLast End If End Sub Private Sub cmdPrev_Click() rs.MovePrevious If rs.BOF Then rs.MoveFirst cmdPrev.Enabled = False End If MoveFields cmdNext.Enabled = True End Sub Pls. tell me, where I am wrong. Thanks

    T 1 Reply Last reply
    0
    • R Ranjita Ghosh

      Hi Everybody! I am using VB6.0 & SQL Server 7.0 Following is my database Connection code Dim db As ADODB.Connection Dim rs As ADODB.Recordset Dim sql As String Set db = New ADODB.Connection db.Provider = "SQLOLEDB" db.ConnectionString = "server=SUNANDA;uid=sa;pwd=ranjita1;database=crm" db.Open Set rs = New ADODB.Recordset sql = "Select * from AccountHead" Set rs.ActiveConnection = db rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open sql, , , , adCmdText I have placed navigation buttons on my form, but the Next & Previous buttons are not working properly. When I first time clicks the Next button , the recordset goes to the next record but when I click it second time, the record doesn’t get changed. When I press the previous button, the recordset points to the first record, instead of pointing to the previous record. Here is my code for navigational buttons:^): Public Sub MoveFields() txtAcId.Text = rs("AcHeadID") txtAcName.Text = rs("AcHeadName") txtAcMobile.Text = rs("Mobile") txtAcEmail.Text = rs("EmailID") End Sub Private Sub cmdFirst_Click() rs.MoveFirst MoveFields cmdPrev.Enabled = False cmdNext.Enabled = True End Sub Private Sub cmdLast_Click() rs.MoveLast MoveFields cmdNext.Enabled = False cmdPrev.Enabled = True End Sub Private Sub cmdNext_Click() rs.MoveNext If rs.EOF Then rs.MoveLast cmdNext.Enabled = False End If MoveFields cmdPrev.Enabled = True End Sub Private Sub cmdRemove_Click() rs.Delete rs.MoveNext If rs.EOF Then rs.MoveLast End If End Sub Private Sub cmdPrev_Click() rs.MovePrevious If rs.BOF Then rs.MoveFirst cmdPrev.Enabled = False End If MoveFields cmdNext.Enabled = True End Sub Pls. tell me, where I am wrong. Thanks

      T Offline
      T Offline
      Tushar Kothari
      wrote on last edited by
      #2

      Hi Dear Please first check where you write the code for recordset and connection. Then try following code for your record movement **Next record **if not rs.eof then rs.movenext() .... end if **previous record **if not rs.bof then rs.moveprevious() ..... end if If the problem is there then please post new message with you complete form code so I can sort your issue. Regards :)

      Tushar kothari********

      R 1 Reply Last reply
      0
      • T Tushar Kothari

        Hi Dear Please first check where you write the code for recordset and connection. Then try following code for your record movement **Next record **if not rs.eof then rs.movenext() .... end if **previous record **if not rs.bof then rs.moveprevious() ..... end if If the problem is there then please post new message with you complete form code so I can sort your issue. Regards :)

        Tushar kothari********

        R Offline
        R Offline
        Ranjita Ghosh
        wrote on last edited by
        #3

        I have written the code for recordset and connection in sub main() I am calling the procedure in each click event.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups