带有简要说明的 ADODB 错误代码表位于 ADO Programmer's Reference > ADO API Reference > ADO Enumerated Constants。
有个说明:
OLE DB 错误可能会传递到您的 ADO 应用程序。通常,这些
可以通过 Windows 设施代码 4 来识别。例如,
0x8004。
还要确定HRESULT 错误代码是否为ADODB 错误,此附加说明表明:
十六进制 - 完整错误号的十六进制表示。
Windows 设施代码在第四位。设施代码
ADO 错误编号为 A。例如:0x800A0E7B。
另请参阅 Microsoft 的 [MS-ERREF]: Windows Error Codes,其中包含指向 Microsoft 文档的 pdf 的链接,其中包含相当全面的代码列表及其描述。有一个 RSS 提要订阅更新通知。
查看来自 Symantech 的非常全面的 Error Codes list for Microsoft technologies 列表。
请参阅此Wikipedia topic HRESULT,描述 Microsoft 用于 HRESULT 错误代码的错误代码格式。从主题中,关于如何使用位的格式是:
S - Severity - indicates success/fail
0 - Success
1 - Failure
R - Reserved portion of the facility code, corresponds to NT's second severity bit.
1 - Severe Failure
C - Customer. This bit specifies if the value is customer-defined or Microsoft-defined.
0 - Microsoft-defined
1 - Customer-defined
N - Reserved portion of the facility code. Used to indicate a mapped NT status value.
X - Reserved portion of the facility code. Reserved for internal use. Used to indicate HRESULT values that are not status values, but are instead message ids for display strings.
Facility - indicates the system service that is responsible for the error. Example facility codes are shown below (for the full list see [1]).
1 - RPC
2 - Dispatch (COM dispatch)
3 - Storage (OLE storage)
4 - ITF (COM/OLE Interface management)
7 - Win32 (raw Win32 error codes)
8 - Windows
9 - SSPI
10 - Control
11 - CERT (Client or server certificate)
...
Code - is the facility's status code
The ITF facility code has subsequently been recycled as the range in which COM components can define their own component-specific error code.
一些更常见的代码是:
adErrItemNotFound - -2146825023 or 0x800A0CC1 - Item cannot be found in the collection that corresponds to the requested name or ordinal.
adErrNoCurrentRecord - -2146825267 or 0x800A0BCD - Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
adErrObjectNotSet - -2146824868 or 0x800A0D5C - Object is no longer valid.
我自己做的一个程序员错误导致在执行Update() 时 HRESULT 为 0x800A0CC1 是我没有正确设置 SAFEARRAY。见usage differences between _variant_t, COleVariant, CComVariant, and VARIANT and using SAFEARRAY variations。