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. Cannot edit the existing record

Cannot edit the existing record

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelp
6 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 buttons on the form to Add, Delete, Edit and Update the records of the table. But in the click event of the Update button, the recordset is not supporting the Edit method. The only method it is showing in (VBA) the dropdown list is EditMode. How will I then Edit the records? Pls. help me out. Thankyou.

    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 buttons on the form to Add, Delete, Edit and Update the records of the table. But in the click event of the Update button, the recordset is not supporting the Edit method. The only method it is showing in (VBA) the dropdown list is EditMode. How will I then Edit the records? Pls. help me out. Thankyou.

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

      Hi Dear please concentrate on your following code rs.CursorType = adOpenStatic As you had open the cursor in Static mode there is no edit permission for this record set. You gave to open the recordset in non static mode. Regards

      Tushar kothari

      R 1 Reply Last reply
      0
      • T Tushar Kothari

        Hi Dear please concentrate on your following code rs.CursorType = adOpenStatic As you had open the cursor in Static mode there is no edit permission for this record set. You gave to open the recordset in non static mode. Regards

        Tushar kothari

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

        Hi! Tushar I have tried with rs.CursorType=adOpenDynamic But of no use. Pls. suggest. regards ranjita

        T 1 Reply Last reply
        0
        • R Ranjita Ghosh

          Hi! Tushar I have tried with rs.CursorType=adOpenDynamic But of no use. Pls. suggest. regards ranjita

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

          Hi If you want just to update the record in recordset then you have to set the fileds values of rs then call rs.update If this method is not wirking the please relpy back then I will try some odd solution for you. Regards

          Tushar kothari

          R 1 Reply Last reply
          0
          • T Tushar Kothari

            Hi If you want just to update the record in recordset then you have to set the fileds values of rs then call rs.update If this method is not wirking the please relpy back then I will try some odd solution for you. Regards

            Tushar kothari

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

            I wants to edit the existing record and then update. what u r suggesting that i am using in the click event of my save button. regards ranjita

            T 1 Reply Last reply
            0
            • R Ranjita Ghosh

              I wants to edit the existing record and then update. what u r suggesting that i am using in the click event of my save button. regards ranjita

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

              Hi This is the tested code so please use it Private Sub Form_Load() Dim db As ADODB.Connection Dim rs As ADODB.Recordset Dim sql As String Set db = New ADODB.Connection db.Provider = "SQLOLEDB" db.ConnectionString = "Provider=SQLOLEDB.1;Password=thk;Persist Security Info=True;User ID=thk;Initial Catalog=Dhanavantari;Data Source=TUSHAR" db.Open Set rs = New ADODB.Recordset sql = "Select * from WardMaster" Set rs.ActiveConnection = db rs.CursorLocation = adUseServer rs.CursorType = adOpenDynamic rs.LockType = adLockPessimistic rs.Open sql, , , , adCmdText End Sub on Save client button rs.Fields(1) = trim(txtwardname.text) rs.Fields(2) = val(txtrate.text) rs.Update So now you can edit the recordset and then update it ADO is the connected type of recordset so you can update one record at a time. If you have some other problem which i had not understand the please brief it regards :)

              Tushar kothari

              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