Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiple Apps Accessing a common Table Bombs on Open Exc
Message
From
08/04/1998 14:52:12
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00090537
Message ID:
00090554
Views:
29
>In my project there are two applications that use a common table to relay information from one to the other. At one point I need to open the table exclusively so it can be cleaned up. If the App1 has it open and App2 is trying to open it exclusively then the" FIle Access is Denied" error comes up. Is there a way to determine by App2, whether or not App1(or any other app) has the table opened. This is a free table.

Create another table with the following structure (call it 'syslocks'):

Tablename C(40)
UsedExcl L

Index on Tablename TAG tablename

When you need to open the table exclusively (assume table is called 'common'):

USE syslocks IN 0 ORDER tablename
SEEK 'common' IN syslocks
IF FOUND('syslocks')
IF syslocks.usedexcl
USE IN syslocks
=MESSAGEBOX("Another user has this table locked up!",16,"Application")
RETURN
ENDIF
ELSE

* Create record if not found

INSERT INTO syslocks (tablename) VALUES ('common')
ENDIF

* Set usedexcl flag with TRUE

SELECT syslocks
REPLACE usedexcl WITH .T.
USE IN syslocks

*
* USE common exclusive and do whatever you need. The close it and...
*

USE syslocks IN 0 ORDER tablename
SEEK 'common' IN syslocks

*
* Set usedexcl FLAG to false
*

IF FOUND('syslocks')
REPLACE syslocks.usedexcl WITH .F.
ENDIF
USE IN syslocks
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Previous
Reply
Map
View

Click here to load this message in the networking platform