Click here to Skip to main content
15,881,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL Execution error

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

How to solve the timeout expired issue?
Posted
Comments
Malli_S 14-Sep-12 7:16am    
In what case does it times out? While connecting or executing ?
If possible show up some code.
Swathi Nagaraj 14-Sep-12 8:16am    
when I execute the following lines in server explorer, Raising SQL Execution error
Select Distinct EmployeeId, FName, LName from fn_Employee

Change Connection string to increase time out:
Data Source=SomeDBServer;Initial Catalog=SomeDB;Provider=SQLNCLI10.1;Integrated Security=SSPI;Auto Translate=False;Connect Timeout=60;
 
Share this answer
 
v3
Comments
Swathi Nagaraj 17-Sep-12 5:55am    
sqlcommand.CommandTimeout = 120;

This works fine sometimes, but sometimes rasies time out expired exception.
I want to know the reason, why it doesn't work sometimes?
Execute the query in Database side and verify where exactly the problem is,

Some of the problem causes,

It may be due to lock of that table,
There is no proper index creation on that table
May be there is a bunch of records like some lacks in that case create a maintainance plan to reorganize the indexes,
If you want the data for OLAP then put a nolock in the query,
Still you face the problem then check your command time out value from your application and change it accordingly.
 
Share this answer
 
Hi,

I guess your transaction is processing the query on Large data, or some database connection problem may be there. The DB connection you have to find the cause but for the processing the large data below link may help you.

Improve the performance[^]

hope it helps.
 
Share this answer
 

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