Handling SQL-DMO Errors

At the highest level, a SQL-DMO object member function succeeds or fails. Every COM function returns an HRESULT value indicating success or failure. The operating system reserves ranges of function return values for COM and OLE errors, and defines specific error conditions such as success and success with additional information.

All SQL-DMO interfaces support the IErrorInfo interface. With an instance of any SQL-DMO object, QueryInterface for an ISupportErrorInfo interface returns a valid interface pointer, and ISupportErrorInfo::InterfaceSupportsErrorInfo returns NOERROR. Therefore, the COM GetErrorInfo function returns an IErrorInterface reference for any error raised by SQL-DMO (HRESULT is greater than CO_E_LAST), and the SQL-DMO application can avoid querying for ISupportErrorInfo.

The SQL-DMO errors enumerated data type SQLDMO_ERROR_TYPE is defined as groups of related errors. The macro SQLDMO_ECAT_MASK, defined in Sqldmo.h, can be used to determine the error category allowing error handling based on type of error returned. For example, SQLDMO_ERROR_TYPE defines SQLDMO_ECAT_UNPRIVILEGEDLOGIN, a category indicating that the currently connected user is not a member of a role with sufficient privilege to perform a requested action. An application may decide to branch to extraordinary error handling code when receiving errors of this category.


(c) 1988-98 Microsoft Corporation. All Rights Reserved.