This documentation is archived and is not being maintained.


Use this macro to call any ODBC API function that may return SQL_STILL_EXECUTING.



An ODBC API function. For more information about ODBC API functions, see the Windows SDK.

AFX_ODBC_CALL repeatedly calls the function until it no longer returns SQL_STILL_EXECUTING.

Before invoking AFX_ODBC_CALL, you must declare a variable, nRetCode, of type RETCODE.

Note that the MFC ODBC classes now use only synchronous processing. In order to perform an asynchronous operation, you must call the ODBC API function SQLSetConnectOption. For more information, see the topic "Executing Functions Asynchronously" in the Windows SDK.

This example uses AFX_ODBC_CALL to call the SQLColumns ODBC API function, which returns a list of the columns in the table named by strTableName. Note the declaration of nRetCode and the use of recordset data members to pass parameters to the function. The example also illustrates checking the results of the call with Check, a member function of class CRecordset. The variable prs is a pointer to a CRecordset object, declared elsewhere.


   SQL_NTS, (SQLTCHAR*)strTableName.GetBuffer(), SQL_NTS, (SQLTCHAR*)NULL, SQL_NTS));

if (!prs->Check(nRetCode))
   AfxThrowDBException(nRetCode, prs->m_pDatabase, prs->m_hstmt);
   TRACE(_T("SQLColumns failed\n"));

Header: afxdb.h