CDaoException::CDaoException
Constructs a CDaoException object.
CDaoException( );
Remarks
Ordinarily, the framework creates exception objects when its code throws an exception. You seldom need to construct an exception object explicitly. If you want to throw a CDaoException from your own code, call the global function AfxThrowDaoException.
However, you might want to explicitly create an exception object if you are making direct calls to DAO via the DAO interface pointers that MFC classes encapsulate. In that case, you might need to retrieve error information from DAO. Suppose an error occurs in DAO when you call a DAO method via the DAODatabases interface to a workspace's Databases collection.
To retrieve the DAO error information
Construct a CDaoException object.
Call the exception object's GetErrorCount member function to determine how many error objects are in the database engine's Errors collection. (Normally only one, unless you are using an ODBC data source.)
Call the exception object's GetErrorInfo member function to retrieve one specific error object at a time, by index in the collection, via the exception object. Think of the exception object as a proxy for one DAO error object.
Examine the current CDaoErrorInfo structure that GetErrorInfo returns in the m_pErrorInfo data member. Its members provide information on the DAO error.
In the case of an ODBC data source, repeat steps 3 and 4 as needed, for more error objects.
If you constructed the exception object on the heap, delete it with the delete operator when you finish.
For more information about handling errors in the MFC DAO classes, see the article Exceptions: Database Exceptions.
Requirements
Header: afxdao.h