Results 1 to 3 of 3

Thread: I want updata database of Microsoft Access but VB6.0 warning error

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    522

    I want updata database of Microsoft Access but VB6.0 warning error

    Code:
    Set objConnection = New ADODB.Connection
    objConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=App.Path & "\database.mdb";Persist Security Info=False;Jet OLEDB:Database Password="123"
    objConnection.Open
    Set rsData = New ADODB.Recordset
    rsData.Open "dulieuxuly", objConnection, adOpenKeyset, adLockOptimistic
    
    Dim i, j As Single
    
        j = 10
        For i = 1 To j Step 1
            rsData.AddNew
            rsData!Num = i
        Next
        rsData.Update
      'The command line in above very good but the command line below warning error
    
       j = 24
       rsDulieu.MoveFirst
       For i = 15 To j Step 1
           rsData!Num = i    ' Warning Error in here (A)
           rsData.MoveNext
       Next
       rsData.Update
    (A): The Microsoft Jet database engine stopped the process because you and another user are attempting to change the same data at the same time.
    I want to update fields rsData!Num = i , can you help me ?
    Last edited by Hack; May 2nd, 2009 at 07:06 AM. Reason: Add Code Tags

  2. #2
    Lively Member
    Join Date
    Mar 2007
    Posts
    82

    Re: I want updata database of Microsoft Access but VB6.0 warning error

    Your problem is that u have a number of j "Addnew" commands and only one Update...The number shoud be the same so i think that putting also rsData.Update before Next will solve your problem

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: I want updata database of Microsoft Access but VB6.0 warning error

    Thread moved to Database Development forum (the "VB6" forum is meant for questions which don't fit in more specific forums)

    corneagigi is correct about that, and note that it applies to both of your loops - for the second loop the .Update should be before the .MoveNext

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