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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check if table is accessible

Status
Not open for further replies.

mensudb

Programmer
Sep 2, 2004
13
US
Hi,

I am working with free tables which are on a server. Sometimes, when my program try to access any of tables, I get an warning screen telling me that alias for the table could not be found.
Is there any way to check out if the table can be opened or accessed before I commit any changes in the table?

Thanks

Mensud
 
Mensud,
This is really a hardware or network configuration problem and not a program one - first determine why your are getting these errors. On a properly configured network you won't get these errors.

Programatically, you should of course include at least some error handling. If you are running VFP 8.0+, then you can use the TRY ... CATCH ... FINALLY technique, otherwise you can use the ON ERROR handling and on forms it's error method to trap and deal with almost all errors.

For a starting point, read Doug Hennig's article on this topic - "Error Handling in Visual FoxPro" - Note: Don't be discouraged if the concepts are overwhelming at first, I read the article, heard him talk about it, and then read the article again before some of the ideas made sense. It's really worth the time spent understanding this information.

Rick
 
You can use the function FILE() to check if the table exists or is accessable.
Code:
IF FILE("mytable.dbf")    
    USE mytable
ELSE
    *** User message file not found
ENDIF

mytable can be the file name or the full path+file name eg
FILE("H:\mydir\mytable.dbf") but you must include the file extension.



Bob Palmer
The most common solution is H2O!
 

I suspected that the problem is in hardware, but since our infrastructure is "pure" mess, I am trying to do what I can.

Thanks a lot.

Mensud


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top