如何解决时间过期异常 [英] How to solve Time Expired Exception

查看:92
本文介绍了如何解决时间过期异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨亲爱的所有



可以告诉我如何解决我的asp .net网站应用程序中的时间过期错误。

我使用了存储过程,执行大约需要2分钟。这个SP用于某种验证目的,使用3个表。这3个表包含数百万个数据。但是执行时间仅为2分钟左右。当我运行aspx页面时,我得到以下给出的错误:



--------------

System.Data.SqlClient.SqlException(0x80131904):超时已过期。操作完成之前经过的超时时间或服务器没有响应。在System.Data.SqlClient.SqlConnection.OnError(SqlException异常,布尔breakConnection)处于System.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,布尔breakConnection)的System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()处于System.Data System.Data.SqlClient.SqlCommand的System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior,String resetOptionsString)中的.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj) System.Data.SqlClient.SqlCommand的System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String方法,DbAsyncResult结果)中的.RunExecuteReaderTds(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean async)。 InternalExecuteNonQuery(DbAsyncResult结果,String methodName,Boolean sendT oPipe)位于e:\\\\\\\\\\ br />
---------------------



我把500s超时web配置文件,也试过cmd.CommandTimeout = 500;在代码后面。我得到同样的错误..如果有人对此有任何想法,请帮助我。



谢谢...

解决方案

@Subhash,



你能不能在web.config文件中增加时间! 默认值为20分钟



 <  配置 >  
< system.web >
<! - 以下代码示例在Web.config文件中将超时会话属性设置为30分钟。 - >
< sessionstate mode = InProc cookieless = true 超时 = 30 / >
< / system.web >
< / configuration >


 <   pre     lang   =  xml >  
您可以使用Sesstion状态模式SqlServer。
< sessionstate < span class =code-attribute> mode = SQLServer sqlconnectionstring = 集成安全性= SSPI;数据源=。; / > 并按以下步骤在Sql Server中设置此模式:

步骤1)在sql server中运行此命令
EXECUTE sp_configure'show advanced options ',1
重新配置覆盖
Go

执行sp_configure'Agent XPs',1
重新配置覆盖
go

EXECUTE sp_configure'show advanced options',0
重新配置覆盖
Go
步骤2-打开Visual Studio命令提示符&am磷;转到
C:\ Windows \ Microsoft.NET.NET \ Framework \v4.0.30319>
执行
aspnet_regsql.exe -S MCC30 -E -ssadd -sstype p

3-打开Web.Config文件&写在< System.web > tag

< sessionState mode = SQLServer sqlConnectionString = 集成安全性= SSPI;数据源= SampleServerName; / >

注意: - 使用[Serializable] Annotation使您的类Serializable在会话中存储该类的数据。


< blockquote>如果你已经尝试了从后端500分钟,并且它没有工作,你有数百万的记录。

我测试了我的数据库是t对于11,000条记录,大约需要2到3分钟。

因此,可能需要花费大量时间进行数百万次重新编码。



你可以用更少的数据来选择而不是整个记录。你可以在命令时间长度再试一次增加

 cmd.CommandTimeout = 1800; // 30分钟


Hi Dear All

could any one please tell me how to fix the time expired error in my asp .net web site application.
I have used a stored procedure and it will take around 2 minutes for execution. this SP is used for some kind of validation purpose using 3 tables.These 3 tables contains millions of data.But the excecution time is only arround 2 minutes.When ever I run the aspx page I got the below given error:

--------------
System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at ASP.claimvalidation_aspx.btn_Click(Object sender, EventArgs e) in e:\ICE\claimvalidation.aspx:line 1362

---------------------

I have put 500s timeout in web config file and also tried cmd.CommandTimeout=500; at code behind.Still I am getting the same error.. Kindly help me if anyone has any idea about this.

Thank You ...

解决方案

@Subhash,

Can you please increase time out in web.config file as well! The default value is 20 minutes

<configuration>
  <system.web>
     <!-- The following code example sets the timeout session attribute to 30 minutes in the Web.config file. -->
    <sessionstate mode="InProc" cookieless="true" timeout="30" />
  </system.web>
</configuration>


<pre lang="xml">
you can use Sesstion state mode "SqlServer".
<sessionstate mode="SQLServer" sqlconnectionstring="Integrated security=SSPI; data source=.;" /> And set this mode in Sql Server in the following steps:

step 1 ) Run this command in sql server
EXECUTE sp_configure 'show advanced options', 1
Reconfigure with override
Go

Execute sp_configure 'Agent XPs', 1
Reconfigure with override
go

EXECUTE sp_configure 'show advanced options', 0
Reconfigure with override
Go
step 2-  Open Visual Studio Command Prompt & Go to
C:\Windows\Microsoft.NET\Framework\v4.0.30319>
Execute
aspnet_regsql.exe -S MCC30 -E -ssadd -sstype p

3-  Open Web.Config File & write inside  <System.web> tag

<sessionState mode="SQLServer" sqlConnectionString="Integrated security=SSPI; data source=SampleServerName;"/>

Note: - Make your class Serializable by using [Serializable] Annotation to store the data of that class in session.


If you have tried with 500 minutes from back end and it's not working where you have millions of record.
I have tested my db is taking approximate 2 to 3 minutes for 11 thousand of records.
So it may take lots of time for millions of recode.

And you can consume less amount of data with for to select instead of whole the record. and you can try again in your commandtimeout length to increase

cmd.CommandTimeout=1800;//with 30 minutes


这篇关于如何解决时间过期异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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