When an error occurs inside SQLAPI++ library it throws an exception of type SAException. The recommended way to process errors is to catch a reference to SAException class.

The following complete example shows a common pattern for handling library exceptions:

#include <stdio.h>  // for printf
#include <SQLAPI.h> // main SQLAPI++ header

int main(int argc, char* argv[])
    SAConnection con; // create connection object
        // connect to database
        // in this example it is Oracle,
        // but can also be Sybase, Informix, DB2
        // SQLServer, InterBase and ODBC
            _TSA("test"),     // database name
            _TSA("tester"),   // user name
            _TSA("tester"),   // password

        printf("We are connected!\n");

        // Disconnect is optional
        // autodisconnect will ocur in destructor if needed

        printf("We are disconnected!\n");
    catch(SAException &x)
        // SAConnection::Rollback()
        // can also throw an exception
        // (if a network error for example),
        // we will be ready
            // on error rollback changes
        catch(SAException &)
        // print error message
        printf("%s\n", x.ErrText().GetMultiByteChars());
    return 0;

Need Help?
Send an e-mail to support@sqlapi.com if you want to ask code-level questions, if you’re stuck with a specific error or need advise on the library best practices.