Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
417 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
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
kjaswal earned 1500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Viewers will learn the different options available in the Backstage view in Excel 2013.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

772 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