Visual Basic Concepts
Each time the ODBC driver manager is used to carry out an RDO request, an error can be generated by Visual Basic, the ODBC interface, or the remote server. These errors can be of varying severity and in some cases may force the query to be canceled or abandoned.
Any errors generated by Visual Basic trigger a trappable error that you can trap using the On Error statement. Errors generated by the ODBC middleware or by the remote server are placed in the rdoErrors collection. Whenever the ODBC function being called by RDO returns a SQL_ERROR result code, Visual Basic fires a trappable error indicating that an ODBC error has occurred. At this point your code can examine the individual members of the rdoErrors collection for details on what caused the error.
Whenever the return code from the ODBC API function is set to SQL_SUCCESS_WITH_INFO, an Informational message is returned from the data source that does not trigger a trappable error. These messages are placed in the rdoErrors collection.
Visual Basic also produces a trappable error when an error occurs that is not directly related to an ODBC operation. For example, if you execute the CreateQuery method and then try to set the rdoParameters collection, you might trip a trappable error indicating that the object does not exist. This can be caused by RDO's inability to build an rdoParameters collection based on the query's syntax. You can examine the Err and Error properties in your On Error handler to determine what action should be taken.
Once you examine the rdoErrors collection, you can clear its contents by using the Clear method. This prevents the confusion that can occur if you subsequently check the rdoErrors collection for errors, only to discover residual messages from an earlier operation that could have no bearing on the current problem.
When you execute a query, the QueryComplete event fires — whether or not the query executed successfully. You can examine the ErrorOccurred Boolean flag to check for successful completion of the query. In a similar fashion, you can check the ErrorOccurred flag in the Connected event to check for the success or failure of a connection operation.
For More Information See "rdoError Object" or "rdoDefaultErrorThreshold Property" in the Language Reference".