Enabling or Disabling DBC Events

You can enable Database Container (DBC) events directly in code or through the Database Properties Dialog Box.

To enable DBC Events

  1. With the Database Designer open, from the Database menu or the Shortcut menu, select Properties.

  2. In the Database Properties dialog box, select Set Events On.

    This enables the Events File check box, so you can choose to add DBC Event code to an external file instead of stored procedures in the current database. It also changes the structure of the database, so it is no longer compatible with prior versions of Visual FoxPro or the Visual FoxPro ODBC Driver. Setting it off again will make it compatible again.

-Or-

  • Enable Database Events programmatically by using the DBSetProp( ) Function as in the following code:

    DBSetProp(<DBCName>,'Database','DBCEvents',.T.)
    

    The database must be open and current before this function is used. When DBC events are turned on in a database, events and methods (in associated procedure code) in the stored procedures will run.

To disable DBC Events

  1. In an open database, from the Database or the Shortcut menu, select Properties.

  2. In the Database Properties dialog box, clear Set Events On.

    This disables the Events File check box.

-or-

  • Disable Database Events programmatically by using the following code:

    DBSetProp(<DBCName>,'Database','DBCEvents',.F.)
    

DBC events are not available in earlier versions of Visual FoxPro. Attempting to access a DBC events enabled-database from a previous version of Visual FoxPro generates an error.

See Also

Database Container Events | Adding Code to a DBC Event | Using DBC Events