Click here to Skip to main content
12,453,873 members (55,637 online)
Rate this:
 
Please Sign up or sign in to vote.
hi
i am facing time out problem in my appplication

An exception of type 'System.Data.SqlClient.SqlException' occurred in App_Web_om7hrdua.dll but was not handled in user code
 
Additional information: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

i had added timeout in webconfig. but the time out error again come please help
Posted 29-Jan-13 6:21am
balongi1.1K
Comments
Sandeep Mewara 29-Jan-13 12:24pm
   
Sounds like DB connection timeout and not Session. How long your operation takes?

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

The timeout belongs on the connection and/or the command. Setting it in the web.config file doesn't add anything because connections and commands aren't magic - they don't know what this value is. Now, the first thing you have to ascertain is whether it's a connection timeout, or a command timeout. In other words, is the problem because it's taking too long to connect to the database server, or is the command taking too long?

If it's connecting to the server, there are strategies such as connection pooling that can help to alleviate problems - you really need to understand your application architecture though. Make sure that you are freeing up connections so that they can be recycled to the pool and picked up from there, rather than being created from scratch every time - this is an expensive operation.

If it's a command timeout, then you could increase the timeout on the SqlCommand. I say could because command timeouts generally indicate that there's a deeper problem with the code, and an increased command timeout may mask the problem for a while, but it will be sitting there to kick you when you least expect it. If you can isolate where the exception is happening (hint - log your exceptions to get the stack trace) then you should easily be able to isolate the command that is causing the problem. When you do this, you can actually analyse the SQL that's at fault - I would use a SQL Profiler here to really figure out what's going on.
  Permalink  
Comments
balongi 29-Jan-13 12:44pm
   
if i execute procedure in sql than it take 3 minute to get the record
Pete O'Hanlon 29-Jan-13 13:24pm
   
There's your problem then. Your SQL needs to be sorted out. Try to run this SQL in a SQL query profiler, and see what's going on in there. Increasing the SQL timeout is exactly the wrong way to go here.
balongi 29-Jan-13 12:50pm
   
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(TdsParserStateObject stateObj)
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 _Default.Button2_Click(Object sender, EventArgs e) in d:\project\Arrear\WebSite9\Default.aspx.cs:line 63

that the stack trace
how i overcome this
Marcus Kramer 29-Jan-13 13:27pm
   
You overcome this by refactoring the stored procedure to fix the root problem which is the code in the stored procedure.
jibesh 29-Jan-13 13:57pm
   
Fine tune your store procedure using joins if it involves more table re-order the table joins and see what's the best for your result.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 29 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100