Connection to MS SQL Server database closes when application starts c#

Every time i attempt to debug my c# application i start the connection by right clicking on the server explorer but as soon as the application starts the connection closes again (get the red disconnection symbol) and i cannot seem to keep it open. Not sure why this is happening and im sure its nothing to do with the code that has been written as this has only recently started happening.

I think this is also causing another problem i am having where data is not being inserted into the database when an insert command is run.


Try to follow those steps:

  1. Start SQL Server Configuration Manager
  2. Open the SQL Server Network Configuration's node.
  3. Click on the Protocols for MSSQLServer as listed above.
  4. Then in the right hand pane enable TCP/IP.
  5. Now double click TCP/IP to get a dialog window.
  6. If you want to listen on all the IP addresses for the server Select Yes in the Listen All box on the first Protocol tab; otherwise
  7. Select the IP Addresses tab and enable the desired IP addresses by setting Enabled to Yes.

Forgot I hadn't answered this. As Joel suggested, what i was seeing in the Server Explorer where the connection seemed to fail was just the Server Explorer behaving as it should and not the actual problem. The problem with data not being inserted was just a problem with my insert statement. CHECK YOUR STATEMENTS.

Need Your Help

Meaning of () => Operator in C#, if it exists

c# .net delegates operators

I read this interesting line here, in an answer by Jon Skeet.

On Standalone Tomcat server how much higher value - maxThreads and maxConnections can be set?

java apache tomcat webserver tomcat7

I am using tomcat server for webservice and found two properties maxThreads and maxConnections defined as in :