Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Closing a .dbf File
Message
 
À
27/09/2004 12:35:45
Mike Smith
Doncaster Office Services
Oakville, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00946324
Message ID:
00946343
Vues:
15
You can not open the DBF exclusive if somebody open it (no metter exclusive or not). Function USED() return if the file is opened by You not if the file is open generaly by someone. To bypass the error You can code somthing like this

* If You use VFP 8:
if used("MyFile")
   USE IN MyFile
endif

TRY
  SELECT 0
  use MyFile excl
CATCH 
  MessageBox("Somone keeps the file open", 0)
ENDTRY
if .NOT. used("MyFile")
  SELECT 0
  use MyFile SHERED
ENDIF
* If You use earlier versions of VFP
if used("MyFile")
   USE IN MyFile
endif
old_error = ON("ERROR")
fl_error = .f.
ON ERROR fl_error = .t.

SELECT 0
use MyFile excl
IF fl_error .OR. .NOT. used("MyFile")
  MessageBox("Somone keeps the file open", 0)
  use MyFile SHERED
ENDIF
ON ERROR &old_error
HTH


>I am now realizing that my current code will not work on a Network with multiple users.
>
>i.e. Suppose I need exclusive access to a .dbf file that could be shared by other users.
>
>I would normally write:
>
>if used("MyFile")
> select MyFile
> use
>endif
>
>use MyFile excl
>
>I now realize that used("MyFile")
>returns .t. if I am using it
>but returns .f. if somewone else is using it on the same Server.
>
>Is there some way of taking over a file exclusively that someone else is already using non exclusively over a Network?
>
>Mike Smith
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform