Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

BeforeModifyConnection, AfterModifyConnection

These Database Events fire when a connection is modified in the Connection Designer.

Usage

PROCEDURE DBC_BeforeModifyConnection( cConnectionName )

PROCEDURE DBC_AfterModifyConnection( cConnectionName, lChanged )

Parameter

Value

Meaning

cConnectionName

Character

The name of the connection.

lChanged

Logical

Indicates whether the connection was changed.

As is the case with other before-and-after pairs of events, you can prevent a connection from being modified (the Connection Designer won’t appear) by returning .F. in the BeforeModifyConnection event, while the AfterModifyConnection event simply receives notification that something happened.

Like other connection-related events, VFP refuses to execute the method of an object in these events when they're fired visually (that is, when you choose Connections from the Database menu to display the Connections dialog and then click Modify). For example, suppose you have code like the following:

PROCEDURE DBC_BeforeModifyConnection(cConnectionName)
loObject = NEWOBJECT('MyClass', 'MyLibrary.VCX')
loObject.SomeMethod()

If you trace this code, you'll see the object being instantiated, but the call to SomeMethod is skipped over as if it were a comment line.

Example

* This goes in the stored procedures of a database.

PROCEDURE DBC_BeforeModifyConnection(cConnectionName)
WAIT WINDOW PROGRAM() + CHR(13) + ;
    'cConnectionName: ' + cConnectionName

PROCEDURE DBC_AfterModifyConnection(cConnectionName, lChanged)
WAIT WINDOW PROGRAM() + CHR(13) + ;
    'cConnectionName: ' + cConnectionName + CHR(13) + ;
    'lChanged: ' + TRANSFORM(lChanged)

* End of stored procedures.
* Create a connection, and then modify it.

CREATE CONNECTION TestConnection DATASOURCE TasTrade
MODIFY CONNECTION TestConnection

See Also

BeforeCreateConnection, BeforeRenameConnection, BeforeDeleteConnection, Create Connection, Database Events, Modify Connection