These Database Events fire when a connection is created (either visually in the Connection Designer or programmatically with the CREATE CONNECTION command) or removed (visually in the Connections dialog for the database or programmatically with DELETE CONNECTION).
PROCEDURE DBC_BeforeCreateConnection()
PROCEDURE DBC_AfterCreateConnection( cConnectionName,
cDataSourceName,
cUserID, cPassword,
cConnectionString )
PROCEDURE DBC_BeforeDeleteConnection( cConnectionName )
PROCEDURE DBC_AfterDeleteConnection( cConnectionName )|
Parameter |
Value |
Meaning |
|
cConnectionName |
Character |
The name of the connection. |
|
cDataSourceName |
Character |
The name of the ODBC data source for the connection. |
|
cUserID |
Character |
The user name for the connection. |
|
cPassword |
Character |
The password for the user name. |
|
cConnectionString |
Character |
The connection string for the connection. |
As is the case with other before-and-after pairs of events, you can prevent the connection from being created or removed by returning .F. in the Before event, while the After events simply receive notification that something happened.
* This goes in the stored procedures of the database.
PROCEDURE DBC_BeforeCreateConnection()
WAIT WINDOW PROGRAM()
PROCEDURE DBC_AfterCreateConnection(cConnectionName, ;
cDataSourceName, cUserID, cPassword, cConnectionString)
WAIT WINDOW PROGRAM() + CHR(13) + ;
'cConnectionName: ' + cConnectionName + CHR(13) + ;
'cDataSourceName: ' + cDataSourceName + CHR(13) + ;
'cUserID: ' + cUserID + CHR(13) + ;
'cPassword: ' + cPassword + CHR(13) + ;
'cConnectionString: ' + cConnectionString
PROCEDURE DBC_BeforeDeleteConnection(cConnectionName)
WAIT WINDOW PROGRAM() + CHR(13) + ;
'cConnectionName: ' + cConnectionName
PROCEDURE DBC_AfterDeleteConnection(cConnectionName)
WAIT WINDOW PROGRAM() + CHR(13) + ;
'cConnectionName: ' + cConnectionName
* End of stored procedures.
* Create a connection, and then remove it.
CREATE CONNECTION TestConnection DATASOURCE TasTrade
DELETE CONNECTION TestConnectionBeforeModifyConnection, BeforeRenameConnection, Create Connection, Database Events, Delete Connection

