• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 111
  • Last Modified:

Database Connection Issue

WE have a website that is having issues connecting to a database on our server.  Some days it works and some days users are not able to connect ( Timeout error ).

Connection String:
"User Id=<id>;Password=<password> Catalog=<catalog>;Server=<servername>; Connection Timeout=120;"

Open in new window

If I change server = "localhost" then I am able to connect to the server, but after a few days someone will complain they timeout again.  In order to get the website to work, i have to keep changing the connection string ( server = servername or server = localhost ) when someone timesouts.

We haven't figured out what the problem is, so I came here looking for suggestions.  My IT Director doesn't think it has anything to do with DNS.

A few comments:
- Website: ASP.NET 2008, Visual Basic
- Only around 5 employees access the website
- The problem usually is reported around the same time of day, but that could be that is the only time they use the program
- We have multiple websites/applications accessing the same server with no problems
4 Solutions
To help here is difficult but I also think this has nothing to do with DNS.

But if you have many applications and just one of them has this problem then you have to investigate IIS settings. (I suppose you are using IIS.) Do all these applications use one App pool? Does App Pool recycling help instead of conn str update?
Double check the handling in the application that experiences issues. To make sure the conect ions are not left hanging.

Another option is to look at connection pooling.

You are not providing information .........on which
Radhakrishnan RSenior Technical LeadCommented:

Which operation system the website running under?. When the issue occurs, what's the resource usage on the server? I.e - Is the memory or CPU jumping to higher?

If the CPU spikes out, and you have the web.config file, then check this line <httpRuntime maxRequestLength="4096" />. Do you have this line? if not, ignore. But monitor the CPU/Memory usage at the time of issue.
Mike LazarusAct! Evangelist - CRM ConsultantCommented:
If localhost times out, it definitely not DNS.
Have you looked for anything in the IIS Logs and windows EventViewer Logs around the time it happens?

You might try adding a Connect Timeout in the web.config
<add key="DBConnection" value="server=LocalHost;uid=sa;pwd=;database=DataBaseName;Connect Timeout=200; pooling='true'; Max Pool Size=200"/>

If always at the same time, you might think about what else happens ... I recall one site where the cleaner unplugged a network router to use the vacuum cleaner. Took a while before I cottoned on :-(
mmsiAuthor Commented:
I'm going to have someone look into IIS to see if that is the problem.  When the web app was first created I didn't have these issues but I think around the time we moved everything to a new server is when people started getting timeouts.

I'm closing this question for further investigation.  Thank you for the replies.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now