Solved

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

Posted on 2009-07-03
3
393 Views
Last Modified: 2012-05-07
I have developed windows project using visual studio 2005 with C# and sql express 2005.
In this project i am using attached mdf method for sql connecting string.
Mdf files attached in my local sytem (application path).
After build, I have installed successfully in another system.
while execute the exe first time  erroer will appear "Timeout expired. the time out period elapsed prior to completion of the operation or the server is not responding".
but next its working properly.. how to fix this problem.
Please any one help to solve this issue.

Thank you for your help.


StrConnSql1 = @"Server=.\SQLExpress;AttachDbFilename=|DataDirectory|\Data\d1.mdf; Database=testDB;Trusted_Connection=Yes;";
 
i am using the following connecting string

Open in new window

0
Comment
Question by:autopartsasia
[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
3 Comments
 
LVL 2

Accepted Solution

by:
kjaswal earned 500 total points
ID: 24773882
Is the timeout error for the connection or is it for the query you are trying to execute?  If the connection is timing out, you can add a "Connect Timeout=X" at the end of your connection string; where X is the number of seconds to wait for a connection to the server before terminating the attempt and generating an error.  So your connection string would look like:

StrConnSql1 = @"Server=.\SQLExpress;AttachDbFilename=|DataDirectory|\Data\d1.mdf; Database=testDB;Trusted_Connection=Yes;Connect Timeout=30";

for a 30 second timeout.  On the other hand, if your query is timing out, then you need to set the timeout on the actual SqlCommand object.  This is done via the SqlCommand.CommandTimeout property.  Again, this value is in seconds, see this link for a reference: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout(VS.71).aspx
0
 

Author Closing Comment

by:autopartsasia
ID: 31599482
Great
0
 

Author Comment

by:autopartsasia
ID: 24775994
Its is connection time out.. thanks for your help..
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

735 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