Connecting to an ODBC database is a three-step process:
Create an ODBCEnvironment object.
Create an ODBCConnection object.
Connect to a DSN (Data Source Name).
.env = ODBC_AllocEnvironment();
.conn = .env.AllocConnection();
/* Attempt to connect. */
ret = .conn.Connect ("DSN name", "user name", "password");
if (ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO)
error (.conn.GetDiagRec());If the connection fails, the return value will be something other than
SQL_SUCCESS or SQL_SUCCESS_WITH_INFO.
You can query the database for details of the failure by calling the
GetDiagRec method of the ODBCConnection.