SQL Server 命令超时 - 仅限可执行文件

发布于 2024-10-19 17:09:35 字数 609 浏览 4 评论 0原文

我收到一条错误消息:

System.Data.SqlClient.SqlException: 超时已过。

我将此追溯到命令超时,默认设置为 30 秒。果然,分析后,在 30 秒内完成(失败)。

简单的答案是增加代码中的 CommandTimeout 值。问题是 - 我只有一个可执行文件可以使用。

正在运行的查询是一个存储过程,通常运行时间为 18-26 秒,最近已增加到 30 秒以上。我已尽我所能来优化查询,该查询是对三个带有连接的表进行的一个丑陋的选择。无论如何,这并不是一个真正的选择,因为数据集将继续增长,并且将来会再次成为问题。

我在这里和网上其他地方找到的所有建议都表明,唯一可以设置 CommandTimeout 的地方是在连接建立后的代码中,并且没有其他方法可以调整命令超时。

我准备开始反编译可执行文件以尝试覆盖/设置命令超时的默认值。有关

如何以非编程方式增加命令超时值、轻松设置命令超时值或其他一些建议(希望)更明智的解决方案?

感谢您的帮助!

ps - 我已经读了很长一段时间了。我的名声很臭,因为我总是不用发帖就能找到答案。你们太棒了,我很高兴我终于找到了开始的方法!

I'm receiving an error message:

System.Data.SqlClient.SqlException:
Timeout expired.

I've traced this back to a command timeout which by default is set to 30 seconds. Sure enough, when profiled, completes (failed) at 30 seconds on the dot.

The easy answer would be to increase the CommandTimeout value in the code. Here's the catch - I only have an executable file to work with.

The query being run is a stored procedure that runs between 18-26 seconds normally and recently has been bumping up into the 30+ second range. I've done everything I can to optimize the query which is a single ugly select on three tables with joins. This isn't really an option anyways as the dataset will continue to grow and will be a problem again in the future.

All advice I could find here and elsewhere on the net says the only place CommandTimeout can be set is in the code after the connection is set up and there is no other way to adjust the command timeout.

I'm about ready to start decompiling the executable to try to override/set the default value of the command timeout..

Any suggestions on how I can non-programmatically increase the command timeout value, get the command Timeout value set easily or some other (hopefully) more sensible solution?

Thanks for your help!

ps - I've been reading SO for quite a while now. My reputation stinks because I always find the answer without having to post. You guys are awesome and I'm glad I finally found a way to get started!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吐个泡泡 2024-10-26 17:09:35

更改命令超时的唯一方法是更新代码,如果您没有应用程序的源代码,我很遗憾地说您运气不好。

这是一个逐个命令设置的值,因此命令外部的任何内容都不会影响它。

The only way that you can change the command timeout is to update the code, if you don't have the source to the application I'm sorry to say that you are pretty much out of luck.

That is a value that is setup command-by-command, so anything external to the command will not impact it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文