Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Freeing a Table From a DBC
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00670670
Message ID:
00670699
Vues:
20
This message has been marked as a message which has helped to the initial question of the thread.
Hi Bret.

Is there a programmatic way to check for a table's link to a DBC
LPARAMETERS tcTable

LOCAL lnHnd, lnHdrStart, lnHdrSize, lcBackLink

*** Check that the file exists
IF ! FILE( tcTable )
   ERROR "9000: Cannot locate file " + tcTable
   RETURN .F.
ENDIF

*** Open the file at low level - Read Only if just reading info
lnHnd = FOPEN( tcTable, IIF( lnParms > 1, 2, 0) )

*** Check file is open
IF lnHnd > 0
   *** Backlink is last 263 bytes of the header so calculate position
   *** Max header size is (32 + ( 255 * 32 ) + 264) = 8456 Bytes
   lcStr = FREAD( lnHnd, 8456 )
   *** Field records end with 13 NULLS + "CR"
   lcFieldEnd = REPLICATE( CHR(0), 13 ) + CHR(13)
   lnHeaderStart = AT( lcFieldEnd, lcStr ) + 13
   *** Move file pointer to header start position
   FSEEK( lnHnd, lnHeaderStart )
   *** Read backlink
   lcBackLink = UPPER( ALLTRIM( STRTRAN( FGETS( lnHnd, 263 ), CHR(0) ) ) )
ELSE
   *** Mayday mayday! Cannot open table  
ENDIF
and then remove the link to the DBC before I open the table up?

But be careful about removing the backlink. You could have more trouble than you have bargained for if long field names are being used.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform