Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Method that fires before the data session is selected?
Message
From
10/04/2008 14:31:32
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01309739
Message ID:
01309773
Views:
9
Use the default datasession. But do not try to open the table via the datasession. Instead enclose the command in a TRY-ENDTRY inside a custom procedure:
PROCEDURE CheckForExclusive
LOCAL lcTable, llExclOK
lcTable = <path> + <tablename>   && This is whatever path and table
TRY
  USE (lcTable) IN 0 ALIAS excltest EXCLUSIVE
  llExclOK = .T.
  SELECT excltest                && Not sure if you want to close here or 
  USE                            &&   at end of program
CATCH TO loException
  llExclOK = .F.
ENDTRY
RETURN llExclOK
ENDPROC
You can call this as appropriate for your application. You can also do this with a small file. Open it with FOPEN() and this will work. You can set the FOPEN handle to a global attribute:
PROCEDURE CheckForExclusive
LOCAL lcFile
IF !PEMSTATUS(_VFP,"ExclusiveUse",5)
  ADDPROPERTY(_VFP,"ExclusiveUse",0)
ENDIF
lcFile = <path> + <Filename>   && This is whatever path and file
TRY
  _VFP.ExclusiveUse = FOPEN(lcFile,0)
CATCH TO loException
  _VFP.ExclusiveUse = -1
ENDTRY
ENDPROC
Then before the program closes, or whenever you don't want to have exclusive use, perform the following:
PROCEDURE ReleaseExclusive
  =FCLOSE(_VFP.ExclusiveUse)
  _VFP.ExclusiveUse = 0
ENDPROC
You can always check the status of exclusive access via the _VFP.ExclusiveUse being set to positive value.
Previous
Reply
Map
View

Click here to load this message in the networking platform