CDBException Class

Represents an exception condition arising from the database classes.

class CDBException : public CException

Name

Description

CDBException::m_nRetCode

Contains an Open Database Connectivity (ODBC) return code, of type RETCODE.

CDBException::m_strError

Contains a string that describes the error in alphanumeric terms.

CDBException::m_strStateNativeOrigin

Contains a string describing the error in terms of the error codes returned by ODBC.

The class includes two public data members you can use to determine the cause of the exception or to display a text message describing the exception. CDBException objects are constructed and thrown by member functions of the database classes.

Note Note

This class is one of MFC's Open Database Connectivity (ODBC) classes. If you are instead using the newer Data Access Objects (DAO) classes, use CDaoException instead. All DAO class names have "CDao" as a prefix. For more information, see the article Overview: Database Programming.

Exceptions are cases of abnormal execution involving conditions outside the program's control, such as data source or network I/O errors. Errors that you might expect to see in the normal course of executing your program are usually not considered exceptions.

You can access these objects within the scope of a CATCH expression. You can also throw CDBException objects from your own code with the AfxThrowDBException global function.

For more information about exception handling in general, or about CDBException objects, see the articles Exception Handling (MFC) and Exceptions: Database Exceptions.

Header: afxdb.h

Show: