Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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 ...
Posted
Comments
ZurdoDev 22-May-14 8:02am    
The error is a SQL timeout so I would suppose you may be setting the cmd timeout incorrectly. Perhaps not the right cmd?

@Subhash,

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

HTML
<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>
 
Share this answer
 
Comments
Pravuprasad 22-May-14 9:28am    
Your solution is partially correct . Its solution is to increase default timeout in web.config which takes value in secs . And this time out should be within connectionstring tag.
SubhashRokzzz 23-May-14 0:39am    
Sorry Sir,

It doesn't work form me...
Pravuprasad 23-May-14 6:43am    
Try to use the entity framework . By doing this you can give default time out in web.config as well as in modelcontext class . If you are interested then give reply.
XML
<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.
 
Share this answer
 
v2
Comments
SubhashRokzzz 23-May-14 0:39am    
Sir
This is also doesn't work for me....
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
 
Share this answer
 
Comments
SubhashRokzzz 23-May-14 8:03am    
Hi sir
I tried this but its also not working....still I am getting the same error...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900