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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
Viewers will learn the different options available in the Backstage view in Excel 2013.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

746 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

9 Experts available now in Live!

Get 1:1 Help Now