Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Error in VB "Couldn't save. currently locked by another user."

Posted on 1997-05-04
Medium Priority
Last Modified: 2006-11-17
I've write a multi-user database system using VB4 under Netware 3.12 network (about 40 users).

In this system, all recordsets are opened in shared mode.

Sometimes, the warning message will be displayed when my users want to save or update data into database. This situation is un-predictable.

The error message is "Couldn't save; currently locked by user 'name' on machine 'name'. (Error 3186)".

According the help in VB4, the explaination is :-
"You tried to save a record on a 2K database page that is currently locked by another user.  Wait for the other user to finish working with the record, and then try the operation again."

However, I sure that nobody is currently locking the table.

After I restart the program, the problem is the same.

Is it a multiuser JET/Access environment problem in VB ?
If yes, how to solve it ? If no, what's problem and how to solve it ?

Thank you very very much !
Question by:raymondc050497
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

davem043097 earned 200 total points
ID: 1425962
When a user updates a record, it's important that some other user isn't allowed to update the same record at the same time. Different databases use different methods to ensure this. Some lock only the record being updated. Some also lock the records immediately before and after. Access locks the 2k page on which the record appears. While this may be simple to implement and/or efficient, it isn't very friendly to other users, since their completely unrelated updates can be locked out while the original update's in progress. Though there's nothing you can do about the 2k page locking, there are things you can do to limit its impact on users. On of the arguments to OpenRecordset (called lockedits) specifies whether you'll be using pessimistic or optimistic locking. Briefly, optimistic locking locks the record only as long as it takes to update the record in the database. Pessimistic locking locks the record (and the 2k page around it, remember) between the call to the edit method and the eventual update. The advantages and disadvantages are pretty obvious. Locks are held longer with pessimistic locking, but you're a lot more sure that updates will work, your users are guaranteed to see the most up to date data, and updates won't accidentally be clobbered by someone else's almost simultaneous update (last one wins). Transactions imply pessimistic locking (i.e. locks are held for the duration of the transaction, even if you're using optimistic locking). Pessimistic locking can be really bad if a user begins an edit or transaction then leaves for lunch, because in Access they're holding a lock not only on their record but on any other record that happens to fall on the same 2k page. There's no simple answer for how to deal with all this, but I hope this discussion gives you some understanding of what's occurring in your app. In brief, to minimize locking conflicts, don't use transactions and do use optimistic locking. Just be aware of the tradeoffs that come with these approaches.

Author Comment

ID: 1425963
Thank you very much!
In fact, I already know your proposed answer before.

However, I can't use the optimisitic locking and without transaction.
It is so dangerous and make large impact to users.

In my program, I use the pessimistic locking with transaction.
After user presses save button, I lock the record and resolve data and then save into database.

I think that it isn't related to this problem. It is because the problem is sometimes happened even though only one user is using the program after one user exits the program.

In other case, users sometimes can't update record using the True DBGrid (bound mode) in my program.

The above mentioned problems are happened uncertanity and un-predictable.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question