Nick
Nick

Reputation: 500

Visual Foxpro "File in use" using "Use Exclusive"

I am coding delete/pack routine in Visual Foxpro 8.0.

I am getting "File in use" when running the following code when the "Use" statement uses "Exclusive":

    USE dbbudget_log EXCLUSIVE
    DELETE ALL 
    pack
    use
    SET SAFETY ON 

I have even tried SET EXCLUSIVE ON/OFF and still get "File in use" error.

Any suggestion eliminating the error?

Best Regards, Nick

Upvotes: 0

Views: 3382

Answers (1)

Cetin Basoz
Cetin Basoz

Reputation: 23797

It means that the file is being used in another session already. That session might belong to the user who tried to use exclusively or someone else on the network. Also, use ... EXCLUSIVE does NOT guarantee that the file is used exclusively (if it is already opened in shared mode then it continues to be used in shared mode and no error is raised). You could code defensively against both situations like this:

local llHadError
On error m.llHadError = .T.
select 0
use dbbudget_log exclusive
zap
use
on error
* if m.llHadError && something went wrong
* ....
* endif

Upvotes: 1

Related Questions