Creating a Table Definition
Creating a table in the ActiveX access method memory image (and in the DDFs) can be useful when a data file has no DDF entry associated with it or when creating a new table. The process includes three basic steps:
1
2
3
If you are creating a new table, this would be followed by a fourth step, creating the data file.
*Note: In the same directory, no two files should share the same file name and differ only in their file name extension. For example, do not name a data file Invoice.btr and another one Invoice.mkd in the same directory. This restriction applies because the database engine uses the file name for various areas of functionality while ignoring the file name extension. Since only the file name is used to differentiate files, files that differ only in their file name extension look identical to the database engine.
When creating an empty table, the ActiveX access method must know that the working table should not exist in the current memory image and that all the field and index information should be cleared out. DdfAddTableName serves this function. Unlike DdfAddTable (which adds the current table memory image to the DDF) or DdfModifyTableName (which changes the current table name but maintains all other information), DdfAddTableName creates an extra slot in the current table list and clears out all of the field and index information associated with the blank table. It is recommended that RefreshLocations be set to False when this is done, so as not to create an empty table in the DDFs.
The new, empty memory image can be populated with the DdfModifyLocation, FieldList, and IndexList operations. It can then be written out to the DDFs with DdfAddTable.
Option Base 0
 
'Get the current information directly from the DDF
VAccess1.RefreshLocations = True
 
'Set the VAccess to the correct DDF
VAccess1.DdfPath = “c:\myData”
 
'We now want to work only with the memory image while we 'set up the table
VAccess1.RefreshLocations = False
 
'Create the new table slot in the current memory image
VAccess1.DdfAddTableName “NewTable”
 
'Set the Location
VAccess1.DdfModifyLocation “newTable.mkd”
 
....
<set the field and index information>
....
 
'Save the table to the file – do not overwrite the existing 'definition
'because there should be no existing definition
DdfAddTable False
 
*Note: An entire table definition can be dropped with one call to DdfDropTable. As might be expected, this operation suggests a high degree of finality and should be used with caution.