.NET应用程序的SQL超时 [英] SQL Timeout from .NET Application

查看:62
本文介绍了.NET应用程序的SQL超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个连接数据库的Web应用程序,用于检索和显示一些信息。但是最近发生了很多超时问题,令我感到困惑。我不是IIS配置,也不是SQL 2005配置人员因此我不确定是否有任何设置我可以更改但是没有。

I have a web application that connects to the database to retrieve and display some information. But recently there has been alot of timeout issues happening and it is puzzling me. I'm not a IIS configuration nor am i a SQL 2005 configuration guy so I'm not sure if there are any settings i could have changed but didn't.

  ;

我已将IIS连接超时扩展到600秒,SQL 2005连接也扩展到600。但我仍然面临着这个问题。以下是错误消息。 

I have extended the IIS connection timeout to 600 seconds and the SQL 2005 connection to 600 as well. But still i am facing this issue. Below is the error message. 

抛出了类型'System.Web.HttpUnhandledException'的异常。

Exception of type 'System.Web.HttpUnhandledException' was thrown.

特定错误:

DB.ExecuteDatatable错误:超时已过期。在操作完成之前经过了超时时间或服务器没有响应。

Error at DB.ExecuteDatatable: Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

我已经采取了应用程序在遇到错误时尝试运行的SQL代码直接在管理工作室中运行它。它设法运行,但花了大约1分钟。

I've taken the piece of SQL code that the application was trying to run when it hit the error and ran it directly in the management studio. It managed to run but took around 1 minute.

任何人都可以帮我吗?

 

推荐答案

基于错误不是数据库连接超时,而是命令执行超时。您的查询可能需要很长时间才能执行。作为一个短期解决方案,你
可能会尝试增加Command对象的CommandTimeout属性(而不是连接的ConnectionTimeout属性),但你应该对数据库进行概要分析,看看数据库端发生了什么导致它。在许多情况下,如果未优化,通常是数据库索引导致
此问题。如果您正在使用SQL Server数据库,首先,我建议运行SQL Server附带的SQL事件探查器工具,以查看执行查询所需的时间。


这篇关于.NET应用程序的SQL超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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