Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is table already open under diff alias?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01448039
Message ID:
01448067
Vues:
56
>>>>>Hi,
>>>>>
>>>>>The only way I know how to determine if a table is already open under some unknown alias is by trying to open the table exclusive and catching the error. Is there another way, maybe simpler?
>>>>>
>>>>>TIA.
>>>>
>>>>
>>>>TRY
>>>>  USE YourTable IN 0 EXCLUSIVE
>>>>CATCH
>>>>  MessageBox("The Table is already opened somewhere")
>>>>ENDTRY
>>>>
>>>
>>>Thank you, Borislav. This works but I forgot to mention that I am trying to find out if the file/table is open by "this" user and not by anyone. That is, if another user of this application has this file open (maybe on another computer), the above code will say that the file is already open. But to me this is not important; I need to find out if this datasession has the file open. Do you see what I mean?
>>
>>
>>lnUsedFiles = AUSED(laUsed)
>>lbAlreadyUsed = .f.
>>FOR lnFor = 1 TO m.lnUsedFiles
>>    IF UPPER(JUSTFNAME(DBF(laUsed[lnFor]))) = "THENAMEOFTHEDBF.DBF"
>>       lbAlreadyUsed = .t.
>>       EXIT
>>    ENDIF
>>NEXT
>>IF m.lbAlreadyUsed
>>   MessageBox("The Table is used  in this datasesion")
>>ENDIF
>>
>>
>
>I thought the above would work but it does not. The problem is that I could have the table opened under a different alias loaded in AUSED(). And then I am trying to see if the table is open. For example, if a table MyTable.dbf is open in this datasession under alias MyTable1_Alias and then I am trying to determine if the table MyTable.dbf is open, the above approach would show that NO. But in fact it is open.


That is why I used DBF() function, to return the real name of the table.
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform