Solved

System.Data.SqlClient.SqlException: Timeout expired

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

762 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

20 Experts available now in Live!

Get 1:1 Help Now