How to resolve the Sql Timeout Exception?

Posted by Manimaddu under ASP.NET on 8/12/2014 | Points: 10 | Views : 673 | Status : [Member] | Replies : 3
Hi All..
Actually i am connecting database and enter the data.Sometimes i am getting following exception,How to resolve this issue?

Exception is :-

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

Thanks & Regards,
Mani Kumar



Responses

Posted by: Bandi on: 8/12/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Try below options, set command timeout parameter to 0. It will execute till the end. By default it will timeout in 30 secs.

sqlComm.CommandTimeout = 0;
Check the timeout in connection string, try setting it to max...

data source=ServerName;initial catalog=DataBaseName;uid=ID;pwd=Password;Connect Timeout=120.



On the SQL Server also you can set timeout of a query. Check with SQL Server DBA's to know the Query time out set on servers.

On IIS also you have timeout setting. In IIS --> Website tab --> Connection time out box . Set the max timeout value (in secs) IIS should maintain idle connection .


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Manimaddu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 8/12/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
http://www.experts-exchange.com/Database/MS-SQL-Server/Q_27390921.html

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Manimaddu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naveenhcl on: 9/3/2014 [Member] Starter | Points: 25

Up
0
Down
Hi,

Check the Timeout elapsed time period. If that is minimum then increase the timeline, if your company won't accept to increase the timeline then check the query part by checking below points.

1) Check the server performance.
2) Check the relation between tables.
3) Check the join cases.
4) Remove unwanted joins while fetching data.
5) Remove Grouping clauses, if ti's necessary then only you need to use it.
6) try to avoid Aggregate functions.
etc..

You need to check all the performance cases, if you follow all those then you won't get the timeout error.

Manimaddu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response