Consider this ODBC code...
The problem I'm having is that some ODBC drivers are poorly written, and SQLConnect simply dies with a BAD_EXEC.
I'd like to wrap this in a try block, which should flow through into the following IF.
Is the best solution to set a bool and read it in the IF, or is there a better style?
Code:
nResult = SQLConnect(hdbc,
(UCHAR *)[dsn cStringUsingEncoding:defaultEncoding], SQL_NTS,
(UCHAR *)[userName cStringUsingEncoding:defaultEncoding], SQL_NTS,
(UCHAR *)[password cStringUsingEncoding:defaultEncoding], SQL_NTS);
// if failed to connect, free the allocated hdbc before return
if (nResult != SQL_SUCCESS && nResult != SQL_SUCCESS_WITH_INFO) {
[self logError:nResult forStatement:SQL_NULL_HSTMT];
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
return NO;
}
I'd like to wrap this in a try block, which should flow through into the following IF.
Is the best solution to set a bool and read it in the IF, or is there a better style?
Last edited by a moderator: