SQL_ATTR_QUERY_TIMEOUT未超时 [英] SQL_ATTR_QUERY_TIMEOUT Not Timing Out
问题描述
设置
使用SQL Server 2008 R2.
Using SQL Server 2008 R2.
我有一个对存储过程的ODBC调用,该调用应在3秒钟后通过使用带有SQL_ATTR_QUERY_TIMEOUT参数的SQLSetStmtAttr函数来超时.
I have an ODBC call to a stored procedure that should time out after 3 seconds by using the SQLSetStmtAttr function with the SQL_ATTR_QUERY_TIMEOUT parameter.
SQLSetStmtAttr( command, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)&timeOut, NULL );
测试
我在存储过程中设置了15秒的延迟.确实,存储的proc确实需要超过15秒的时间才能返回.
I set a delay in the stored procedure for 15 seconds. The stored proc does indeed take just over 15 seconds to return.
WAITFOR DELAY '00:00:15'
问题
问题是存储过程正确返回,我期待有一个错误.
The problem is that the stored procedure returns correctly, where I am expecting an error.
有什么想法吗?
推荐答案
发现问题.
timeOut变量(int)作为参考传递到SQLSetStmtAttr,并且参考位置的值远大于3.
The timeOut variable (int) was passed into SQLSetStmtAttr as a reference, and the value of the reference location was much larger than 3.
正确的实现是:
SQLSetStmtAttr( command, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)timeOut, NULL );
这篇关于SQL_ATTR_QUERY_TIMEOUT未超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!