Solved

how to use lock in vb6 application using acess

Posted on 2006-06-12
7
301 Views
Last Modified: 2010-04-07
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
0
Comment
Question by:ziorrinfotech
[X]
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
  • 4
  • 2
7 Comments
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16884219
Hi,

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

"Lock Record"
[ http://www.experts-exchange.com/Databases/MS_Access/Q_21394336.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.
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16884226
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 16884535
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?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Accepted Solution

by:
pradapkumar earned 100 total points
ID: 16885295
to overcome abovesaid problem you can use timout technique.
Add one more column which one will be timestamped.
update that column whenever lock is obtained for that row.
when others try to update that record read the lock column if it is locked then read the timestamp in that column if it is beyond the preset(defined by you as you wish) time out just give lock to that user and update the timestamp. On successful update reset that time stamp column. So, if network crashes next time user may acquire the lock automatically after some period of time.

I thing this may helpful to over come abovesaid problem.

@};-
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 16885498
how long you are going to timeout?

what happen if the app is actually using it. How do you detect?
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16890386
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.
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16892024
I still believe the two questions combined violate an E-E rule of offering more than 500 points per question.
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

726 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