I'm having a problem with the call to SQLGetDiagRec. It works fine in ascii mode, but in unicode it causes our app to crash, and i just can't see why. All the documentation i've been able to find seems to indicate that it should handle the ascii/unicode switch internally. The code i'm using is:
void clImportODBCFileTask::get_sqlErrorInfo( const SQLSMALLINT _htype, const SQLHANDLE _hndle )
{
SQLTCHAR SqlState[6];
SQLTCHAR Msg[SQL_MAX_MESSAGE_LENGTH];
SQLINTEGER NativeError;
SQLSMALLINT i, MsgLen;
SQLRETURN nRet;
memset ( SqlState, 0, sizeof(SqlState) );
memset ( Msg, 0, sizeof(Msg) );
// Get the status records.
i = 1;
//JC - 2009/01/16 - Start fix for bug #26878
m_oszerrorInfo.Empty();
nRet = SQLGetDiagRec(_htype, _hndle, i, SqlState, &NativeError, Msg, sizeof(Msg), &MsgLen);
m_oszerrorInfo = Msg;
}
everything is alright until this function tries to return, then the app crashes. It never gets back to the line of code after the call to get_sqlErrorInfo.
I know that's where the problem is because i've put diagnostics code in and it gets past the SQLGetDiagRec okay and it fnishes this function.
If i comment the SQLGetDiagRec line it works fine.
It always works fine on my development box whether or not it's running release or debug.
Any help on this problem would be greatly appreciated. Thanks