Error- and Message-Handling Interface Syntax

This section describes the syntax for the DB-Library for Visual Basic error and message handlers. VBSQL1_Error is called automatically whenever the application encounters a DB-Library for Visual Basic error. VBSQL1_Message is called in response to messages returned by SQL Server.

VBSQL1_Error Procedure

The VBSQL1_Error procedure has the following syntax:

VBSQL1_Error ( sqlconn%, severity%, errornum%, errorstr$, retcode% )

where

sqlconn%
Is a SQL Server connection that encountered an error.
severity%
Is an integer that denotes the severity of an error. For a list of error severities, see Error Messages.
errornum%
Is an integer, or error number, that denotes an error constant. Error numbers and their corresponding constants are listed in the VBSQL.BAS include file. For a list of DB-Library for Visual Basic error constants and their corresponding error messages, see Error Messages.
errorstr$
Is a string that is the error message for a corresponding error constant. For a list of DB-Library for Visual Basic error constants and their corresponding error messages, see Error Messages.
retcode%
Is an output parameter that determines how DB-Library for Visual Basic will proceed following the error. Custom error handling code can set retcode% to one of the following integers prior to exiting the VBSQL1_Error procedure:
0INTEXIT
Treated as an intcancel error.
1INTCONTINUE
Meaningful only for timeout errors (sqletime). It continues to wait for a second timeout period. At the end of the second period, the error handler is called again. In any other case, this value is considered an error and is treated as an intcancel.
2INTCANCEL
Returns FAIL from the DB-Library for Visual Basic function that caused the error.

For timeout errors (SQLETIME) only, DB-Library will call SqlCancel% in an attempt to cancel the current command batch and flush any pending results. If this SqlCancel% attempt also times out, the connection is broken.

VBSQL1_Message Procedure

The VBSQL1_Message procedure has the following syntax:

VBSQL1_Message ( sqlconn%, message&, state%, severity%, msgstr$ )

where

sqlconn%
Is the SQL Server connection that encountered an error.
message&
Is an integer that is a message number returned by SQL Server. Each number has a corresponding message to which it is associated. For more information about SQL Server messages, see the Microsoft SQL Server Administrator's Companion.
state%
Is the SQL Server state number. The number provides information about the context of the current error.
severity%
Is an integer that denotes the SQL Server severity of an error. For information about SQL Server severities, see the Microsoft SQL Server Administrator's Companion.
msgstr$
Is a message string corresponding to the message number returned by SQL Server. For more information about SQL Server messages, see the Microsoft SQL Server Administrator's Companion.