我需要知道ADODB SQL Server连接返回的Visual Basic 6错误代码列表。我还想知道每个SQL ADODB错误代码的Err.Nativeerror。
我们可以获取这些错误代码的任何信息或任何列出异常和错误代码的VB6代码,以及错误详细信息的描述和错误的含义。
答案 0 :(得分:2)
带有简要说明的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。