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!

Function USE() to verify another computer 1

Status
Not open for further replies.

knela

Programmer
Jan 26, 2007
13
BR
Hello! I would to know something: Can I use the funcition USE() to verify if a table is open in another computer? Thanks for the help!
 
No. The USED() function only tells you if a table is in use in a workarea in the current instance of VFP.

Bill Kuhn - MCSE
bkuhn@kuhngroup.com
The Kuhn Group, Inc.
 
Knela,

The following code will tell you if a table is open, either on another computer or the same computer that is running the code:

Code:
lnError = 0
TRY
  USE MyTable IN 0 EXCLUSIVE
CATCH TO loError
  lnError = loError.ErrorNo
ENDTRY
USE IN SELECT("MyTable")
IF lnError = 1705
  ? "Table is already open"
ENDIF

This is not perfect. It only tells you that the operating system is denying access to the physical file. It could mean that the file is read-only, for example. Also, even if the file is not opened on another computer at the time you execute this code, it doesn't mean that will still be the case when you actually open the table.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top