Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to trap error - File Access is denied
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00694551
Message ID:
00694582
Vues:
27
You can create a class to wrap USE EXCLUSIVE. It will allow to capture error regardless what kind of error handler is in effect. Something like
lcTableName = "test"

oOT = CREATEOBJECT("OpenExclusive")
= oOT.OpenTable(lcTableName)

DO CASE
CASE oOT.nError = 0
  * Table open Exclusive
CASE oOT.nError = 1705
	* Cannot open table Exclusive
OTHERWISE
	* Some other error
ENDCASE	
...
RETURN

DEFINE CLASS OpenExclusive AS Custom
     nError = 0
     PROCEDURE OpenTable(tcTableName)
          USE (tcTableName) EXCLUSIVE 
     ENDPROC
     PROCEDURE Error( tnError, tcMethod, tnLine)
          This.nError = tnError 
     ENDPROC
ENDDEFINE
It isn't complete code but an illustration how it can be done.


>I am opening a file with the EXCLUSIVE clause. If someone else is using the file, I immediately get an error, "File access is denied". I thought that there might be some way to trap this error, but there appears to not be one. I placed an ON ERROR ThisForm.ExclusiveError() function after the "USE TableName EXCLUSIVE" command, but it is never executed; the FoxPro error appears first.
>
>Does anyone know of a way to accomplish the purpose of detecting that the file is already open elsewhere? I want to do some reindexing (rebuild index tags), which the user/administrator executes from a form with a grid of a list of tables. I want to alert the user tyhat someone is still using the open file and that he cannot have exclusive access yet.
>
>Cecil
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform