BeforeAddTable, AfterAddTable, BeforeCreateTable, AfterCreateTable
These database events fire when an existing free table is added to a database (the Add events) or when a new table is created (the Create events).
Usage |
PROCEDURE DBC_BeforeAddTable( cTableName, cLongTableName ) PROCEDURE DBC_AfterAddTable( cTableName, cLongTableName ) PROCEDURE DBC_BeforeCreateTable( cTableName, cLongTableName ) PROCEDURE DBC_AfterCreateTable( cTableName, cLongTableName ) |
Parameter |
Value |
Meaning |
cTableName |
Character |
The name and full path of the DBF file. |
cLongTableName |
Character |
The long name of the table. |
AfterCreateTable is passed the wrong value for the cLongTableName parameter when a table is created visually (that is, in the Table Designer) and the long name is changed from its default value. Although the new long name is correctly stored, cLongTableName receives the original value. |
Example |
* This goes in the stored procedures of the database. PROCEDURE DBC_BeforeAddTable(cTableName, cLongTableName) WAIT WINDOW PROGRAM() + CHR(13) + ; "cTableName=" + cTableName + CHR(13) + ; "cLongTableName=" + cLongTableName PROCEDURE DBC_AfterAddTable(cTableName, cLongTableName) WAIT WINDOW PROGRAM() + CHR(13) + ; "cTableName=" + cTableName + CHR(13) + ; "cLongTableName=" + cLongTableName PROCEDURE DBC_BeforeCreateTable(cTableName, cLongTableName) WAIT WINDOW PROGRAM() + CHR(13) + ; "cTableName=" + cTableName + CHR(13) + ; "cLongTableName=" + cLongTableName PROCEDURE DBC_AfterCreateTable(cTableName, cLongTableName) WAIT WINDOW PROGRAM() + CHR(13) + ; "cTableName=" + cTableName + CHR(13) + ; "cLongTableName=" + cLongTableName * End of stored procedures. * Open the database and turn on DBC events. OPEN DATABASE TestData DBSetProp('TestData', 'Database', 'DBCEvents', .T.) * Create a table in the Table Designer. CREATE TestTable * Create a table programmatically. CREATE TABLE TestTable2 NAME "My Long Table Name" ; (FIELD1 C(10)) * Create a free table, and then add it to the database. CREATE TABLE TestTable3 FREE (FIELD1 C(10)) USE ADD TABLE TestTable3 NAME "Another Long Name" |
See Also |
Add Table, BeforeCreateView, Copy Structure, Copy To, Create, Create From, Create Table, Database Events, Import |