Share via


CDBException Class

Represents an exception condition arising from the database classes.

class CDBException : public CException

Members

Public Data Members

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.

Remarks

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

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.

Inheritance Hierarchy

CObject

CException

CDBException

Requirements

Header: afxdb.h

See Also

Reference

CException Class

Hierarchy Chart

CDatabase Class

CRecordset Class

CFieldExchange Class

AfxThrowDBException

CRecordset::Update

CRecordset::Delete

CException Class