Solved

System.Data.SqlClient.SqlException: Timeout expired

Posted on 2004-08-04
5
13,850 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

932 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now