Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Opening all dbfs in a directory
Message
De
16/10/2013 09:20:38
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01585571
Message ID:
01585599
Vues:
77
I have used this type of solution before in a stand-alone PRG for testing tables (untested code):
PUBLIC nCount, gnDbcnumber, gaDatabase[1], gnBadCount

* Redirect our error handler to display relevant information
ON ERROR DO flagError WITH gaDatabase[nCount, 1]

* Get directory of all DBF files 
gnDbcnumber = ADIR(gaDatabase, '*.DBF')

* Loop for number of tables to find bad ones
gnBadCount  = 0
FOR nCount = 1 TO gnDbcnumber
    * Try to open it
    USE (gaDatabase[nCount, 1]) IN 0 ALIAS thisDbf

    * If it opened, close it
    IF USED("thisDbf")
        USE IN thisDbf
    ENDIF
NEXT

* Restore our error handler
ON ERROR

* Tell the user how it went
? IIF(gnBadCount = 0, "No errors", TRANSFORM(gnBadCount) + " tables could not be opened")


FUNCTION flagError
LPARAMETERS pcTable
    * Note:  you could add additional passed parameters to verify the error message, etc.
    ? "Table " + pcTable + " is bad"
    gnBadCount = gnBadCount + 1
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform