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
365 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 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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 how to maximize accessibility options in an Excel workbook for users with accessibility issues.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

939 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

10 Experts available now in Live!

Get 1:1 Help Now