Solved

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

Posted on 1997-05-04
2
303 Views
Last Modified: 2006-11-17
URGENT QUESTION
===============
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 !
0
Comment
Question by:raymondc050497
2 Comments
 

Accepted Solution

by:
davem043097 earned 100 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.
0
 

Author Comment

by:raymondc050497
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

861 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now