Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Named Pipes Provider, error: 40 - Could not open a connection to SQL Server?

In our project user using NHibernate 2.1.1 with SQL Server 2008 with .net 3.5.

I am facing strange problem with SQL Server. We developed windows service, installed it and it was running fine for sometime. Unfortunately by mistake when I stopped SQL Server, NHibernate throw exception

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)

But after restarting the SQL Server, it is unable to connect to the SQL Server, still throwing the same error. But I am able to connect SQL Server through Query Analyzer / Management Studio.

Please any body can help me in solving the problem?

Thanks

nRk

like image 598
nRk Avatar asked Nov 15 '22 09:11

nRk


1 Answers

I know you already an answer but I got the same error but the solution was different, maybe this will help someone else.

When I was setting up ASP.Net to store the session variables in a DB I got the same error

provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server

The cause of my problem was the database couldn't be found on the SQL Server I was connecting to. Once I create the database correctly everything worked correctly.

Given the cause of the problem I would have expected the error message

provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified

like image 155
TheLukeMcCarthy Avatar answered Nov 17 '22 00:11

TheLukeMcCarthy