Solved

System.Data.SqlClient.SqlException: Timeout expired

Posted on 2004-08-04
5
13,869 Views
Last Modified: 2011-08-18
I am getting the following exception -

System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()

On the google I found I need to update the commandTimeOut property. How much do I need to update it and where should I update it.

My application is windows application

Thanks
0
Comment
Question by:jra2002
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:Arragorn
ID: 11718636
Hi jra2002,

You can change the the timeout period by setting the CommandTimeout property of your command object. This property is in seconds. For Example to set your timeout property to 2 mins (120 secs)
EX:

dim myCmd as SQLCommand
myCmd.CommandTimeout = 120

To determine what to set the timeout to it is important to know why the timeout is occuring. Is this a long running query etc.


John Crenshaw
john.crenshaw@ky.gov
john@jcdl.net

Consultants are people who borrow your watch to tell you what time it is, then walk off with the watch.

0
 

Author Comment

by:jra2002
ID: 11718798
Dear John,
previously I had never has the problem of Timeout Today is the first tine I am getting this error

Thanks
0
 
LVL 4

Accepted Solution

by:
Arragorn earned 20 total points
ID: 11718889
jra2002,

If this is the first time the problem has occured then I would suspect some other external issues such as  A problem with the SQL Server running slow or poorly,  Is anyone else processing on the server and it is just simply to busy?  Or it could be that the some other process on the server is hung or eating up all of the processor time.  I would try and run the same type of query from Query analyser and see what I get.
0
 

Author Comment

by:jra2002
ID: 11719286
Dear Arragorn
You are right. It's not the program error. Database is locked
0
 

Expert Comment

by:cdzuniga
ID: 12128226
I am experiencing the same problem, but it is not timing out from Query Analyzer, only from the app. I have cmd.CommandTimeout = 600 in the class. The server is config'd for the same. But the app times out after 25 sec. What gives?
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question