Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Table Paths
Message
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00057214
Message ID:
00057403
Views:
36
>>>>>Is there a way to get the table paths from the DATABASE (DBC)
>>>>>I tryed to use the ADBOBJECTS with tables but this only returns
>>>>>the name with out the path. When I used the DBC I saw a memo field
>>>>>that conntained the path and table name in it. I was hoping for
>>>>>a simple VFP function that I have missed.
>>>>>
>>>>>Charles
>>>>
>>>>Select table1
>>>>? dbf()
>>>
>>>I should have explained better. I am building a version control
>>>for one of my apps and I try to come up with some solutions to problems.
>>>If the DATABASE is missing I FREE the tables recreate the database and add
>>>the tables back into it. The problem is this:
>>> Create a database
>>> Add several tables
>>> Then delete one table (could happen)
>>> : Now if you try and readd it to the database
>>> : it says table name already used
>>> : Try and drop or delete the table from the database
>>> : and it says it can't find the table.
>>> The only solution I have found it to create a temp table with
>>> the same name free then drop the table from the database. But to
>>> create it so the database can drop it I need it in the same path
>>> as the original.
>>>
>>>
>>>Charles
>>
>>
>>If the .DBF() file has been deleted (doesn't exist) and you simply want to remove it from the database treat the table record and the other records associated with it (fields, relations, views) like records in any other table:
>>
>>SELECT objectid FROM database.dbc INTO CURSOR cMissingTable WHERE objecttype = 'Table' AND objectname = 'missing'
>>DELETE FROM database.dbc WHERE objectid = cMissingTable.objectid OR parentid = cMissingTable.objectid OR (objecttype = 'Relation' AND 'missing' $ property)
>>SELECT database.dbc
>>REINDEX
>>USE
>>USE IN cMissingTable
>>
>>Getting rid of any persistant relationships can be a little sticky IIF you have any tables have field names that are the same as any of the tables in the database (w/o '.dbf'). For a relation, the parentid represents the child table and the property field contains a reference to the parent table.
>>
>>You'd also want to make adjustments for any views based on the missing table....
>>
>>Dan
>
>
>Thanks but how would I know what table is missing without first.
>getting an error or without getting the database path.


Sorry - I thought you already knew the table was missing.

If your're verifying that all tables are present:

1. SELECT objectid,objectname FROM database.dbc WHERE objecttype = 'Table'
2. SCAN the result set
3. SELECT the dbc and LOCATE in the dbc using the objectid (or name) in the result set cursor
4. Try this code to build the file path and name:

cTableName = ALLTRIM(objectname) + '.dbf'
nStart = AT(ALLTRIM(objectname),property)-1
DO WHILE ISALPHA(SUBSTR(property,nStart,1)) OR INLIST(ASC(SUBSTR(property,nStart,1)),92,58) && allow for alphas and '\' and ':'
cTableName = SUBSTR(property,nStart,1) + cTableName
nStart = nStart - 1
ENDDO
5. Use the FILE() function to determine if the file exists.

Is this any closer? :)

Dan
Dan
St. Petersburg, FL

"I started out with nothing and I still have most of it left"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform