The underlying provider failed on Open. provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) - Compiled Stored Procedures


Back to learning
Created: 19/04/2017
Symptom:
The underlying provider failed on Open. ---> System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) 

-Compiled Stored Procedures

Cause:
In my case i had this issue because my app/compiled stored procedure, were trying to acces to "localhost" instance of sql server, but i only had named instance,".\SQLSERVER" so basically configure your sql server in such a way that you can access that instance by typing "localhost"
For example you can test if you done it well, by entering to sql server management and type server "localhost", if you can acces to your instance you are done.

Solution(Worked in SQL Server 2008):
For your named instance, you need to set it to the static default SQL Server port, i.e. 1433. 
TCP/IP will need to be enabled for the instance

SQL Server Configuration Manager -> Sql Server Network Configuration -> Protocols for MSSQLSERVER -> TCP/IP -> Properties -> SET: IPAll -> TCP Port: 1433

More info: