CDBException Class
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

CDBException Class

class CDBException : public CException


A CDBException object represents an exception condition arising from the database classes. 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 articles Overview: Database Programming and DAO and MFC.

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

See Also

Class Members | Base Class | Hierarchy Chart | CDatabase | CRecordset | CFieldExchange | AfxThrowDBException | CRecordset::Update | CRecordset::Delete | CException

© 2015 Microsoft