Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Freeing a Table From a DBC
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00670670
Message ID:
00670704
Views:
15
>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.

Thanks for the reply, what is the code to remove the BackLink?
Bret Hobbs

"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform