ADO/SQL Server:“超时过期"的错误代码是什么? [英] ADO/SQL Server: What is the error code for "timeout expired"?

查看:309
本文介绍了ADO/SQL Server:“超时过期"的错误代码是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试捕获ADO中的超时过期"错误.

i'm trying to trap a "timeout expired" error from ADO.

发生超时时,ADO返回:

When a timeout happens, ADO returns:

Number:      0x80040E31 (DB_E_ABORTLIMITREACHED in oledberr.h)
SQLState:    HYT00
NativeError: 0

NativeError为零是有意义的,因为超时不是数据库引擎(即SQL Server)的函数,而是ADO内部的超时机制.

The NativeError of zero makes sense, since the timeout is not a function of the database engine (i.e. SQL Server), but of ADO's internal timeout mechanism.

Number(即COM hresult)看起来很有用,但是DB_E_ABORTLIMITREACHED的定义="nofollow noreferrer"> oledberr.h 说:

The Number (i.e. the COM hresult) looks useful, but the definition of DB_E_ABORTLIMITREACHED in oledberr.h says:

执行已停止,因为达到了资源限制.没有结果返回.

Execution stopped because a resource limit was reached. No results were returned.

此错误可能适用于"超时已过期"(某些可能在服务器端)以外的事物,例如限制以下条件的调控器:

This error could apply to things besides "timeout expired" (some potentially server-side), such as a governor that limits:

  • CPU使用率
  • I/O读/写
  • 网络带宽

并停止查询.

最后一个有用的部分是SQLState,它是一个独立于数据库的错误代码系统.不幸的是,唯一的我可以找到的SQLState错误代码的引用没有提及HYT00.

The final useful piece is SQLState, which is a database-independent error code system. Unfortunately the only reference for SQLState error codes i can find have no mention of HYT00.

该怎么办? 该怎么办?

What to do? What do do?

注意:我不信任

0x80040E31 (DB_E_ABORTLIMITREACHED)

表示"超时已过期",这超出了我的信任范围

to mean "timeout expired", anymore than i could trust

0x80004005 (E_UNSPECIFIED_ERROR)

表示"事务被另一个进程锁定在锁资源上,并被选择为死锁受害者".

我的伪问题变成:没有人知道SQLState"HYT000"的含义吗?

My pseudo-question becomes: does anyone have documentation on what the SQLState "HYT000" means?

我真正的问题仍然存在:如何特别捕获ADO引发的ADO 超时过期异常?

And my real question still remains: How can i specifically trap an ADO timeout expired exception thrown by ADO?

必须喜欢开发人员试图做正确的事"的问题,但没人知道如何做.也一定喜欢DB_E_ABORTLIMITREACHED的搜索方式,这个问题是#9,MSDN无处可寻.

Gotta love the questions where the developer is trying to "do the right thing", but nobody knows how to do the right thing. Also gotta love how googling for DB_E_ABORTLIMITREACHED and this question is #9, with MSDN nowhere to be found.

OLEdb ICommand.执行引用:

DB_E_ABORTLIMITREACHED

DB_E_ABORTLIMITREACHED

执行已中止,因为已达到资源限制.例如,查询超时.没有返回任何结果.

Execution has been aborted because a resource limit has been reached. For example, a query timed out. No results have been returned.

"例如",表示并非详尽的列表.

"For example", meaning not an exhaustive list.

找到了.答案已应用为答案.

Found it. Answer applied as answer.

推荐答案

可以安全地使用HYT00表示超时已过期" .以下内容来自Microsoft的 SQLSTATEs 参考.它提到了HYT00 SQLSTATE:

You can safely use HYT00 to mean "Timeout expired". The following comes from Microsoft's SQLSTATEs reference. It mentions the HYT00 SQLSTATE:

以下SQLSTATE指示运行时错误或警告,并且是基于其进行编程逻辑的很好的候选对象.但是,不能保证所有驱动程序都会将它们返回.

The following SQLSTATEs indicate run-time errors or warnings and are good candidates on which to base programming logic. However, there is no guarantee that all drivers return them.

01004(数据被截断)

01004 (Data truncated)

01S02(选项值已更改)

01S02 (Option value changed)

HY008(已取消操作)

HY008 (Operation canceled)

HYC00(未实现可选功能)

HYC00 (Optional feature not implemented)

HYT00(超时已过期)

然后链接到附录A:ODBC 《 ODBC程序员参考》的错误代码,其中记录了SQLSTATE值:

Which then links to Appendix A: ODBC Error Codes of the ODBC Programmer's Reference, which documents the SQLSTATE values:

  • HYT00超时已过期,有趣的是,
  • HYT01连接超时已过期
  • HYT00 Timeout expired, and interestingly also
  • HYT01 Connection timeout expired

因此您可以将HYT00用于"超时已过期".

So you can use HYT00 for "Timeout expired".

这篇关于ADO/SQL Server:“超时过期"的错误代码是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆