Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to return the record lock status?

Status
Not open for further replies.

diem

Programmer
Jul 25, 2001
28
0
0
US
Hello everyone,

I'm using VFP 6.0. I have 2 exe are running at the same time. Each exe opens the tables in shared mode. If one exe attempts to lock a record using LOCK() function, how does the other exe find out that record is locked. I tried to use ISRLOCKED() function to test the record lock status, but it only returns the lock status of its current exe, not the status of the other exe. Is there anyway to solve this problem? Any help is appreciated. Thank you
 
You can only tell the record is locked by another user if you try to lock it and get .F. returned:

IF RLOCK()
*... available
ELSE
*... someone else has it locked
ENDIF

IF ISRLOCKED() = .F.
*... someone else has it locked
ELSE
*... available
ENDIF

Dave S.
 
Thanks Dave. Do you know any other way to lock a record without using LOCK() function? My problem is that I need to lock other users from using one particular record, but still be able to update others records. For example, if there are 2 users running program at the same time and try to edit 2 different records. User 1 select one record and using LOCK() function to lock it. Then in some part of the code, it needs to update some fields in the table(record by record). But the problem is User 2 also LOCK() the other record at this point. So, it caused problem "Record is in use by another user".
Is there any way to work around this problem? This program is for multi-users, not just 2. I want to be able to lock the current record and at the same time update other records which might be locked by other users.
Any idea would be appreciated. Thank you.
 
That's the whole purpose of locking a record, so no one can make changes to it while you're trying to make changes to it. If you want to have update access to multiple records, you should lock all the record you need to update prior to making changes to any of them. Setting MULTILOCKS on should give you the ability to do this.

Dave S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top