Partager via


AFX_ODBC_CALL

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

AFX_ODBC_CALL(SQLFunc )

Parameters

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

Remarks

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.

Example

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.

RETCODE nRetCode;

AFX_ODBC_CALL(::SQLColumns(prs->m_hstmt, (SQLTCHAR*)NULL, SQL_NTS, (SQLTCHAR*)NULL,
   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"));
}

Requirements

Header: afxdb.h

See Also

Reference

AFX_SQL_ASYNC

AFX_SQL_SYNC

Concepts

MFC Macros and Globals