|
-
December 15th, 2010, 06:52 AM
#3
Re: Query issues - ODBC Microsoft Access Driver error
 Originally Posted by Maximus_X
When I run a trivial query ("SELECT * FROM myTable") I use the SQLExecDirect().
Code:
nRetCode = SQLExecDirect(m_hSTM, (SQLTCHAR *) szQuery, (SQLINTEGER) wcslen(szQuery));
And now, surprise: nRetCode = -1.
I don't know the HandleError but you should know that there could be multiple error messages. So it needs to calling SQLError in a loop in order to get full information.
You may find out how to program that by evaluating the code below
Code:
Bool OdbcEnvironment::checkSqlReturn(RETCODE ret, String* pInfo, Bool bGetInfo, Bool bUpdate)
{
if (ret == SQL_SUCCESS || (ret == SQL_SUCCESS_WITH_INFO && !bGetInfo))
return True;
if (pInfo == NULL)
return False;
SQLHSTMT& hStmt = bUpdate? m_hStmtUpd : m_hStmt;
UChar szSqlState[10];
UChar szErrorMsg[SQL_MAX_MESSAGE_LENGTH];
Long nativeError;
Short nLenErrorMsg;
String& info = *pInfo;
String newLine;
if (ret == SQL_SUCCESS_WITH_INFO)
info = "SQL_SUCCESS_WITH_INFO " + info;
else
info = "SQL_ERROR " + info;
for (;;)
{
if (SQLError(m_hEnv, m_hDbc, hStmt, szSqlState, &nativeError,
szErrorMsg, SQL_MAX_MESSAGE_LENGTH-1, &nLenErrorMsg) != SQL_SUCCESS)
break;
info << newLine << " | " << String((CharPtr)szSqlState) <<
" : " << String(nativeError) << " | " << String((CharPtr)szErrorMsg);
if (newLine.isEmpty())
newLine = "\n\t";
}
return False;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|