共用方式為


AfxThrowDBException

Call this function to throw an exception of type CDBException from your own code.

void AfxThrowDBException( 
   RETCODE nRetCode, 
   CDatabase* pdb, 
   HSTMT hstmt  
);

Parameters

  • nRetCode
    A value of type RETCODE, defining the type of error that caused the exception to be thrown.

  • pdb
    A pointer to the CDatabase object that represents the data source connection with which the exception is associated.

  • hstmt
    An ODBC HSTMT handle that specifies the statement handle with which the exception is associated.

Remarks

The framework calls AfxThrowDBException when it receives an ODBC RETCODE from a call to an ODBC API function and interprets the RETCODE as an exceptional condition rather than an expectable error. For example, a data access operation might fail because of a disk read error.

For information about the RETCODE values defined by ODBC, see Chapter 8, "Retrieving Status and Error Information," in the Windows SDK. For information about MFC extensions to these codes, see class CDBException.

Requirements

Header: afxdb.h

See Also

Reference

CDBException::m_nRetCode

Concepts

MFC Macros and Globals