ADO.NET的SqlCommand.CommandTimeout如何工作? [英] How does ADO.NET' s SqlCommand.CommandTimeout work?

查看:307
本文介绍了ADO.NET的SqlCommand.CommandTimeout如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑一个存储过程,该存储过程大约在60秒内更新一些行,而无需使用事务。我们设置ADO.NET的 SqlCommand.Timeout 到30秒。

Consider a stored procedure that updates some rows about in 60 seconds without using a transaction. We set ADO.NET's SqlCommand.Timeout to 30 seconds.

SqlCommand.Timeout = 30;

当超时时间为30秒时,存储过程是否继续在数据库服务器中运行?服务器如何将其传达给客户端?

When that timeout occurs at 30 seconds, will the stored procedure continue to run in database server or not? How does the server communicate this to the client?

推荐答案

答案是否定的,您在服务器上尝试执行的操作将在30秒后失败,则SqlCommand对象将在代码中(以下)引发异常,并且隐式存储过程事务将回滚。

The answer is no, your attempted action on the server will fail after 30s, your SqlCommand object will throw an exception in your code (below) and the implicit stored procedure transaction will rollback.

超时已过期。操作完成之前超时时间已过,或者服务器没有响应。

...至少这是我可以验证的行为SQL Server ...

...at least this is the behavior that I can verify using SQL Server...

这篇关于ADO.NET的SqlCommand.CommandTimeout如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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