连接字符串中未超时超时 [英] Timeout not being honoured in connection string

查看:225
本文介绍了连接字符串中未超时超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个长期运行的SQL语句,我想运行,无论我在连接字符串的timeout =子句中,它总是似乎在30秒后结束。

I have a long running SQL statement that I want to run, and no matter what I put in the "timeout=" clause of my connection string, it always seems to end after 30 seconds.

我只是使用 SqlHelper.ExecuteNonQuery()执行它,并让它处理打开连接,等等。

I'm just using SqlHelper.ExecuteNonQuery() to execute it, and letting it take care of opening connections, etc.

有没有别的东西可以覆盖我的超时,或导致sql server忽略它?我在查询中运行了分析器,当我在管理工作室中运行它时,跟我的代码相比,跟踪看起来没什么不同。

Is there something else that could be overriding my timeout, or causing sql server to ignore it? I have run profiler over the query, and the trace doesn't look any different when I run it in management studio, versus in my code.

管理工作室完成查询大约一分钟,但即使超时设置为300或30000,我的代码仍然会在30秒后超时。

Management studio completes the query in roughly a minute, but even with a timeout set to 300, or 30000, my code still times out after 30 seconds.

推荐答案

你在连接字符串中使用什么来设置超时?从内存是ConnectionTimeout,并且只影响实际连接到服务器的时间。

What are you using to set the timeout in your connection string? From memory that's "ConnectionTimeout" and only affects the time it takes to actually connect to the server.

每个单独的命令有一个单独的CommandTimeout 这将是你要找的。不知道SqlHelper如何实现。

Each individual command has a separate "CommandTimeout" which would be what you're looking for. Not sure how SqlHelper implements that though.

这篇关于连接字符串中未超时超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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