Export (0) Print
Expand All
TRY
Expand Minimize

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 Platform 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 Platform 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.

// example for AFX_ODBC_CALL

RETCODE nRetCode;

AFX_ODBC_CALL( ::SQLColumns( prs->m_hstmt,
         (UCHAR *)NULL, SQL_NTS, (UCHAR *)NULL,
         SQL_NTS, (UCHAR *)(constchar*)strTableName,
         SQL_NTS, (UCHAR *)NULL, SQL_NTS ) );

if ( !prs->Check( nRetCode ) )
{
   AfxThrowDBException( nRetCode, prs->m_pdb, 
                        prs->m_hstmt );
   TRACE( "SQLColumns failed\n" );
}

See Also

MFC Macros and Globals | AFX_SQL_ASYNC | AFX_SQL_SYNC

Show:
© 2014 Microsoft