Solve: provider: Named Pipes Provider error: 40 Can not open connection to SQL Server

Problem Description:

        At ambient (SQL Server2008, Win7,32 bit, VS2010 development system), the database connection fails, "that appears associated with a particular network or when to establish a connection to the SQL Server error instance, was not found or can not access the server, verify the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open connection to SQL Server). " As shown below:

solution:

      Since the error has been described may be due to the instance name wrong. So that there are two possibilities, one is SQL service is not open, the second is SQL instance name really wrong.

1. Make sure the service is turned on, we find the setting interface (Control Panel -> Administrative Tools -> Services), as shown below:

 

 Find the SQL Server service, confirm that the service has been opened.

 (Note: SQL default when you install the instance named MSSQLServer, Learning Edition is SQLEXPRESS)

 

2, Web.config file to view the project, testing database instance name (the value of Data Source) connection string is correct.

Such as: I view the configuration of the Data Source = point indication MSSQLServer instance, it can be seen from the above, I use the SQL Express edition database, the correct configuration should be the Data Source = \ SQLEXPRESS. (.).

       Some people would say, I know when to use dot (.), What use. \ SQLEXPRESS, also, or custom instance name. It is also easy to handle this, just take what you can test SQL. Open SQL SERVER Management Studio, our test data in the login, the server name to the point, as shown below (.):

The server name to point (.), Suggesting that mistakes, errors, and the same as above, but we replaced ". \ SQLEXPRESS" will be able to log normal.

 

Circumstances in which it arose:

       In general, the instance name is rarely a configuration error, but if it is a team project, there we are operating normally, but one day suddenly moved to other computer code and database to run it, the difference between different versions of SQL database due to computer (there are enterprise Edition, learning version) may occur this problem, of course, is his own at the time of installation of the SQL instance name to be modified to anything else.

       In addition to the instance name of the problem or service is not open, there is a case that said error may not allow remote connections. The need to "Peripheral Configuration Tool" to modify it.

 

Published 131 original articles · won praise 22 · views 120 000 +

Guess you like

Origin blog.csdn.net/qq_38890412/article/details/104487517