Provider named pipes provider error 40 could not open a connection to SQL Server error 2

Well I have an easy solution for your question. Follow the steps:

  1. Go to SQL Server Configuration manager
  2. SQL Server Network Configuration:
  3. Protocol for MSSQLSERVER
  4. In the right pane split page you will have to disable VIA as follows
    1. Shared Memory - Enable
    2. Named Pipes - Enable
    3. TCP/IP - Enable
    4. VIA - Disable

Search for services in control panel, there you will find and entry View Local Services in Admin tool section

select it that will show a window with all services in your system, find your service SQLEXPRESS and click on Start. It should start your server instance :)

enter image description here


In Sql Server Configuration Manager program, start SQL SERVER, enable the TCP/IP connection. After, allow the port in the firewall to be sure that's ok.

Tags:

C#

Sql Server