LOTUS CONNECTORS


Handling an ODBC error
Example

The ODBCConnection, ODBCQuery, and ODBCResultSet classes all contain the following methods:


These methods are documented under ODBCQuery since they are the same for all three classes. The GetErrorMessage topic documents the error codes and associated error text for each error and provides examples. The documentation for each property and method provides error codes and text for the error paths it contains.

If an operation is successful, the return number is DBstsSUCCESS. Any other number indicates an error.

You can test operations on an individual basis by calling the above methods after each operation. The following code shows the technique for checking the last operation and exiting if an error occurred:


You can test operations in general with an On Error statement. If the On Error action with no error number is in effect, any operation that returns an error number other DBstsSUCCESS invokes the On Error action. Your error code should test GetError for all objects that may cause the error. The following code shows the technique for trapping any ODBC error and exiting:
The default On Error action is Resume Next. If you don't explicitly check for errors and an error occurs, the script continues with undefined results.

Example