Results 1 to 9 of 9

Thread: Error in updating access db. using vb6.....

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2008
    Location
    india, mysore
    Posts
    11

    Exclamation Error in updating access db. using vb6.....

    Hi All..
    I am accessing 2 colums from access database and updating them .


    Option Explicit
    Dim c As New adodb.Connection
    Dim cn As New adodb.Connection
    Dim cm As adodb.Command
    Dim rsnew2 As New adodb.Recordset

    Private Sub cmd_edit_Click()

    If text1.Text = "" Then
    MsgBox " enter the company name"
    text1.SetFocus
    rsnew2.Fields("text1") = text1.Text
    End If
    If text2.Text = "" Then
    MsgBox " enter the company address"
    text2.SetFocus
    rsnew2.Fields("text2") = text2.Text
    End If
    rsnew2.Update
    MsgBox " add new successful ", vbInformation, "successful"

    End Sub

    Private Sub Form_Load()
    Dim cs As String
    c.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\COMION.MDB;Persist Security Info=False")
    rsnew2.Open "select * from company", c, adOpenDynamic
    Me.text1.Text = rsnew2(2)
    Me.text2.Text = rsnew2(3)

    End Sub


    There is error in RSNEW2.UPDATE ..
    CAN ANYBODY HELP ME TO SOLVE MY PROBLEM ??????????

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,515

    Re: Error in updating access db. using vb6.....

    What is the error?

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2008
    Location
    india, mysore
    Posts
    11

    Re: Error in updating access db. using vb6.....

    run time error:::3251
    Current recordset does not support updation..This may be a limitation of the provider or of the selected locktype

  4. #4
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,515

    Re: Error in updating access db. using vb6.....

    You need to add the lock type when you open the recordset, like adLockOptimistic.
    vb Code:
    1. rsnew2.Open "select * from company", c, adOpenDynamic, adLockOptimistic
    It defaults to a read only lock type if you don't

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2008
    Location
    india, mysore
    Posts
    11

    Re: Error in updating access db. using vb6.....

    Still there is an error..
    error is Run time error::3705
    Operation is not allowed when object is open...

  6. #6
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,515

    Re: Error in updating access db. using vb6.....

    what line?

  7. #7

    Thread Starter
    New Member
    Join Date
    Feb 2008
    Location
    india, mysore
    Posts
    11

    Re: Error in updating access db. using vb6.....

    Quote Originally Posted by wes4dbt
    what line?
    error in this line...
    rsnew2.Open "select * from company", c, adOpenDynamic, adLockOptimistic
    I tried by changing renew2 to new recordset i.e (rsnew3) .. I am getting message that "edit is successful", but its not updating in database..

  8. #8
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,515

    Re: Error in updating access db. using vb6.....

    This means that you have already opened the recordset sometime before. I don't see any code where you close the recordset. You should always close the recordset after you use it. You can check if its open like this

    Code:
    if rsnew2.State = adStateOpen then
       '  it is already open
    else
        ' open rs
    end if

  9. #9

    Thread Starter
    New Member
    Join Date
    Feb 2008
    Location
    india, mysore
    Posts
    11

    Re: Error in updating access db. using vb6.....

    Quote Originally Posted by wes4dbt
    This means that you have already opened the recordset sometime before. I don't see any code where you close the recordset. You should always close the recordset after you use it. You can check if its open like this

    Code:
    if rsnew2.State = adStateOpen then
       '  it is already open
    else
        ' open rs
    end if

    rsnew2 or rsnew3????

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width