Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am having an issue from the client server.

I have developed a windows application which receives requests from diff devices and connect to the different APIs and updates the request and responses in the database and also WEB interface to check the record status, different kinds of reports

also a windows service which connects to the database for every 5 seconds and do some process and update the response to the database


suddenly what happens i don't know all the ports on the server stopped listning (unable to receive the requests), database connection fails

i found this error from event log... "login failed for user 'sa'. reason failed to open the explicitly specified database"

what could be the reason..

please help me

Thanks to all.
Posted

Start by checking that your connections are all closed and Disposed: if you aren't doing that, it's quite likely that SQL has run out of connections - particularly if you are creating, opening, and discarding a new connection every 5 seconds...

Put your SqlConnection into a using block and see if that improves things:
C#
using (SqlConnection con = new SqlConnection(strConnect))
   {
   ...
   }
 
Share this answer
 
Comments
sagar.panuganti 15-Jun-15 2:25am    
Thanks,

I am using the same ,application is working fine after some time (5 to 6 hours)of continuous running ,all the ports are blocked even i am unable to connect to sql server and application listner ports also blocked unable to telnet..

to analyze this issue what are the inputs you need i mean like event . even i have no idea what causes this issue

here the server is (windows server 2003,12GB ram,1TB HD), both database and applications are running on same server
how to trace this.
Help me..
OriginalGriff 15-Jun-15 2:39am    
Ah.
Seriously, look at your code.
If it fails after several hours, then the chances are that the available connections are exhausted - which implies that you are creating Connection and Command objects which you aren't closing properly - so the connection remains open until the object is Disposed, which doesn't happen in .Net apps until memory becomes low.

So look at your code, and check your connections - make sure they are Disposed properly when you are finished with them.
sagar.panuganti 16-Jul-15 2:33am    
hi thanks for the response.. not only the sql server but also all the windows server 2003 ports are blocking internet is not working 3party API's are not pinging can you suggest the solution
The "failed to open the explicitly specified database" error means that your connection string specifies a database which doesn't exist, or is off-line. You'll need to check SQL to find the correct database name.

More importantly, your applications should never connect as sa. You should only ever connect using an account with the least permissions required to run your application. Connecting as sa could give an attacker complete control over your server.
 
Share this answer
 
Comments
sagar.panuganti 15-Jun-15 2:25am    
Thanks,

I am using the same ,application is working fine after some time (5 to 6 hours)of continuous running ,all the ports are blocked even i am unable to connect to sql server and application listner ports also blocked unable to telnet..

to analyze this issue what are the inputs you need i mean like event . even i have no idea what causes this issue

here the server is (windows server 2003,12GB ram,1TB HD), both database and applications are running on same server
how to trace this.
Help me..
Richard Deeming 15-Jun-15 6:50am    
As Griff said, it sounds like you're not closing your connections properly.
sagar.panuganti 16-Jul-15 2:34am    
hi thanks for the response.. not only the sql server but also all the windows server 2003 ports are blocking internet is not working 3party API's are not pinging can you suggest the solution
Richard Deeming 16-Jul-15 7:08am    
Talk to your network admin. If you can't connect to the internet, then the problem is not with your code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900