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

Error opening a table with USE command 3

Status
Not open for further replies.

violetstarlight

Programmer
Aug 7, 2002
23
US
For what reasons would the following statement fail:
USE("\\ServerName\FolderName\TableName") SHARED

Troubleshooting an error that happens sporadically where an error is occuring and I'm not sure what that error is because it happens in the middle of the night (the calling program runs constantly looking for print, fax and email jobs on a unix system).

Obviously if the table is locked exclusively someplace else or if the file is inaccessible perhaps because the server is being backed up at that time. Can anyone think of any other reasons the USE command might fail?

Thanks tons!!
Shaun
 
It may just be a timeout because of a network delay.

You might want to try adding an "on error" function that waits a second and tries again.

Brian
 
...the calling program runs constantly ...

Why not open it once and leave it open then?
Dave S.
 
I am new to FoxPro, so you'll have to excuse my lack of knowledge. Can you have more than one table open at a time?

The program it's in uses tons of free tables for many diffrent purposes. It's about 12 years old and the programmer who wrote it is no longer with the company. My area of expertise is in VB.

The program constantly loops thru looking for email, fax and print jobs sitting out in a UNIX directory. As it loops, it opens and closes tables as it needs them.
 
yes, you can have a bunch of tables open at the same time...

USE mytable1 in 0 shared
Use mytable2 in 0 shared
Use mytable3 in 0 shared

all 3 tables will be open at the same time, but in different workareas.

think of each workarea as a recordset object (sort of) and they can be referred to by their aliases (in this case the alias will be the same as the name...you can go back and forth between the tables that are open as well by...

Select mytable1 &&give focus to that workarea
go top &&move record pointer to top of table records
skip 1 &&move record pointer down one record

Select mytable2 &&give focus to that workarea
go top &&move record pointer to top of table records
skip 1 &&move record pointer down one record

Select mytable3 &&give focus to that workarea
go top &&move record pointer to top of table records
skip 1 &&move record pointer down one record

...this is far from an extensive explanation but I too had some problem understanding the data access model if you will when I came over from VB some years ago. Believe me that VFP is much better than VB/Access when it comes to working with the data, you'll get the hang of it!


Slighthaze = NULL
 
Briefly, yes, you can have up to 255 tables open at once.
You select different "work areas", and open tables in them. You can then reference them by alias or reselect that work area and reference them directly.

It will take a little time, but you can modify your code to open all the tables in the beginning, and select them as needed:

SELECT 0 &&... The first available workarea as determined by VFP
USE Table1 &&... The actual .DBF name
USE ("\\ServerName\FolderName\TableName1") SHARED

SELECT 0 &&... The next available workarea as determined by VFP
USE Table2 &&... The actual .DBF name
USE ("\\ServerName\FolderName\TableName2") SHARED

Then in your code instead of having:
USE ("\\ServerName\FolderName\TableName") SHARED
for each task,

SELECT TableName1
DO stuff for that TableName1
.
.
.

SELECT TableName2
DO stuff for that TableName2
.
.
.

At the end of the program, you can then issue
CLOSE ALL
QUIT
to close all the tables and exit.
Dave S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top