Link to home
Start Free TrialLog in
Avatar of ziorrinfotech
ziorrinfotech

asked on

how to use lock in vb6 application using acess

I am working on an vb6 application with access.

I want to make it multiuser. SO if any user edit the data or record then all the other user get a msg that record is beig use until the first user finhes her work on that record.

So how to use locks to implements that
Any samples codes is there
Avatar of [ fanpages ]
[ fanpages ]

Hi,

Please note my comment regarding soft-locking in this PAQ:

"Lock Record"
[ https://www.experts-exchange.com/questions/21394336/Lock-Record.html ]

You could apply "soft locking", that is, have an additional column, say "Locked", that you would set to 'True' (or 'Y', or whatever) upon first usage, and reset to 'False' ('N' etc) when the use of the record was concluded (i.e. unlocked).

All users would query this "Locked" column on each record before usage, and if set to 'True' ('Y' etc), then would report that the record was locked.


BFN,

fp.
Don't think there is any good solution for that.

fanpages's will work only if your application will not crash or you app does not access via network.

The question is who is going to reset the flag if network connection is off and your app is crash?
ASKER CERTIFIED SOLUTION
Avatar of pradapkumar
pradapkumar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
how long you are going to timeout?

what happen if the app is actually using it. How do you detect?
Hi,

I use an expanded approach in my applications.

I have a [LOCK] table that defines the table (or set of records) being locked, the LAN user name of the user requesting the lock, & the date/time that the lock was requested.

If the same table (or set of records) is requested to be locked by another user, and it is (they are) currently flagged as locked, and the user is still logged-in to the database, then a message is display to "...try again later...".  This, however, can be overridden if a preset time has been exceeded; typically 5 minutes.  During the update process of the locked table/records, the code checks to see if a [LOCK] record is still in place for that user, and if it is, then the update can continue; but if a [LOCK] record no longer exists, or exists for another user, then a prompt is displayed to say that the timeout was reached, and a new user now has a lock in place.  An option is presented to refresh the form (data) will the most up-to-date data, wait for the lock to be released, or abandon the changes completely.

However, if a record is found for the same table/records & the user is no longer logged-in then the previous [LOCK] record is deleted, and a new record is created for the current user requesting the lock.

Additionally, whenever the database is opened, the [LOCK] table is purged of any records for a user that is no longer logged-in.

BFN,

fp.
I still believe the two questions combined violate an E-E rule of offering more than 500 points per question.