Skip to content

ODBC Errors

All ODBC calls return a result code. The most common result codes are the following:


SQL_SUCCESS indicates that the call was successful. SQL_SUCCESS_WITH_INFO indicates that the call completed successfully, possibly with a nonfatal error (warning). The Client will sometimes suppress such warnings if they are expected; in all other cases, these warnings are displayed. SQL_ERROR indicates that the call encountered an error. In case of errors, the Client will interrogate ODBC to get the details of the error it displays.

Diagnostic messages may include several error messages. Each of these errors includes an SQLSTATE that provides detailed information about the cause of a warning or error and a diagnostic message that includes a native error code (generated by SQL Server). An example of such an error is:

RetCode = SQL_SUCCESS_WITH_INFO, SQLState = 01000; native_error = 5701, error = [Microsoft][SQL Native Client][SQL Server]Changed database context to 'TESTDB'.

This message is generated when the Client connects to the database. The native error of 5701 is generated by SQL Server.

The following example illustrates an error that typically occurs during the fixup phase. The client suppresses such messages during the fixup phase, but displays them during the change tracking phase.

RetCode = SQL_ERROR, SQLState = 23000; native_error = 2601, error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert duplicate key row in object 'customer' with unique index 'customer_set'.

In some situations you may get multiple error messages caused by the same event. These kinds of error messages are generated at different levels of the ODBC interface. The Client uses the native_error code in all cases that involve errors generated by the database.