Setting Up the Error- and Message-Handling Interface

The error-handling interface between your application and DB-Library for Visual Basic is provided by a custom control. When you add this custom control to your application, it installs two error handler event procedures, assigns them the default names VBSQL1_Error and VBSQL1_Message, and supplies the appropriate parameter list as part of each procedure name.

You must explicitly include the DB-Library for Visual Basic procedures for handling errors in your application's primary form before you can use them in your application. These error-handling procedures are contained in the VBSQL.VBX file as part of a custom-control tool that is represented by a stop sign icon in the Toolbox palette. You can place only one error-handler control in an application.

    To include the error-handling procedures in your application
  1. From the File menu, choose Add File to add the file VBSQL.VBX (available in the C:\SQL60\BIN directory by default) to your Project.

    Visual Basic adds the VBSQL.VBX file to your Project window and adds the VBSQL.VBX error handler to the bottom of the Toolbox as a custom control that is shown as a stop sign.

  2. Select the error-handler custom control and place it on your startup form. Only a single copy of the VBSQL.VBX control should be used for an application. The form containing the VBSQL.VBX should remain loaded as long as the DB-Library application is running, and it should be the last form unloaded when the application ends.

    It appears on the form with a default name of VBSQL1. (Since the VBSQL1 custom control requires no action from the user to make it active, you can set its Visible property to FALSE (0) to make it invisible.) The code for the startup form now includes the object VBSQL1 and includes procedure templates for two error event handlers: VBSQL1_Error and VBSQL1_Message.

To implement your error handlers, add code to these event procedures to perform whatever specialized error handling is appropriate to your application. Note that you can also rename the error-handler custom control using the Properties window.