none
How to resolve error "Could not update: Currently locked"

    Question

  • I have developed a project using VB.net and access 2003. It is executing without any error in IDE, but when I created the setup file and executed then once it is executing currently and once I am getting error "Could not update: Currently locked" and the software gets terminated.

    I am using ADO.net and uses the following code to open a recordset.

    Can any

    Dim rs as new ADODB.Recordset 
    
     rs.Open("Select * from table", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockPessimistic)

    Can anyone please help me to solve my problem:( Urgently required!!

    Thank you in advance


    Friday, March 24, 2017 6:25 AM

Answers

  • The error indicates that more than one is user is attempting to edit a specific row or a row within the same page of rows or within a transaction. I don't see the line of code where the exception occurs but you might want to try using a client-side cursor by setting the CursorLocation of rs to adUseClient and the CursorType to adOpenStatic. Also, using pessimistic locking will attempt to lock a row or page when an edit occurs. You may want to use optimistic locking, which only locks at the time of update.

    Also, remember to avoid persistent connections.


    Paul ~~~~ Microsoft MVP (Visual Basic)

    • Marked as answer by Tabzee Friday, March 24, 2017 8:59 PM
    Friday, March 24, 2017 12:33 PM

All replies

  • Maybe you should later execute rs.Close and Set rs = Nothing.

    Friday, March 24, 2017 6:36 AM
  • You are not using Ado.Net, you are using standard old ADO even with LockPesimistic. 

    Maybe use another lock type. Be aware that in Ado.Net only optimistic locking is used. 


    Success
    Cor

    Friday, March 24, 2017 7:54 AM
  • The error indicates that more than one is user is attempting to edit a specific row or a row within the same page of rows or within a transaction. I don't see the line of code where the exception occurs but you might want to try using a client-side cursor by setting the CursorLocation of rs to adUseClient and the CursorType to adOpenStatic. Also, using pessimistic locking will attempt to lock a row or page when an edit occurs. You may want to use optimistic locking, which only locks at the time of update.

    Also, remember to avoid persistent connections.


    Paul ~~~~ Microsoft MVP (Visual Basic)

    • Marked as answer by Tabzee Friday, March 24, 2017 8:59 PM
    Friday, March 24, 2017 12:33 PM
  • Maybe you should later execute rs.Close and Set rs = Nothing.

    Thank you !!!!

    It really helped me.

    Friday, March 24, 2017 8:58 PM
  • Hi Paul, 

    I should change my tongue, but to reassure you, I do not do,  just like the newsgroups times I've more fun helping youngsters.




    Success
    Cor



    Friday, March 24, 2017 9:09 PM