Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
How to rename a table of a database?
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01178413
Message ID:
01178413
Views:
59
I am having a tough time create a little routine to rename a table in a database. I want to add a TEMP table to a database of the same structure as one of the existing. Then drop the original table and rename the TEMP table into the original.

Here is what I do:
cTblName = "MyTable"
use (cTblName)
afields(aDbfStruct)
set database to MyDatabase
create table TEMP name TEMP from array aDbfStruct
close tables
drop table (cTblName)
rename table ("TEMP") to (cTblName)
*-- I was hoping that rename table will rename actual file name
*-- but it does not. So I have to do this:
rename ("TEMP.DBF") to (cTblName + ".DBF")
rename ("TEMP.FPT") to (cTblName + ".FPT")
But the table MyTable.DBF is not part of the database after all of that.

What am I missing?

Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Next
Reply
Map
View