Visual C++ 6 Unleashed

Visual C++ 6 Unleashed

By MICKEY WILLIAMS and David Bennett

Exception Handling

The MFC database classes report most errors by throwing exceptions rather than returning error codes. For errors specific to database operations, a CDBException object is thrown, although other exception types, such as CMemoryException, also may be thrown.

When handling an exception, you can simply use the CException::ReportError() function to alert the user to the exception, or you may do more extensive error processing based on the member variables of the CDBException. These include m_nRetCode, which gives the ODBC SQLRETURN value that was generated; m_strError, which holds a string with text describing the error; and m_strStateNativeOrigin, which holds a string containing the SQLSTATE, native error, and error message string, including the ODBC component that generated the error.

Share ThisShare This

Informit Network