JOsh
JOsh

Reputation: 167

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.

Upvotes: 0

Views: 1737

Answers (2)

JOsh
JOsh

Reputation: 167

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.

Upvotes: 0

user6176844
user6176844

Reputation:

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.

Upvotes: 1

Related Questions