How do I fix the error 'Named Pipes Provider, error 40 - Could not open a connection to' SQL Server'?

前端 未结 30 2538
借酒劲吻你
借酒劲吻你 2020-11-22 08:27

I can\'t seem to connect to my database from a site. I get this error:

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

相关标签:
30条回答
  • 2020-11-22 09:03

    Use SERVER\\ INSTANCE NAME .Using double backslash in my project solved my problem.

    0 讨论(0)
  • 2020-11-22 09:03

    After following all the steps mentioned here, if it still does not connect, try adding the DNS with the IP address in the hosts file in the etc folder. Adding an IP address instead of DNS name in the connection string should be a temporary solution to check if the connection actually works.

    0 讨论(0)
  • 2020-11-22 09:04

    And the simplest solution - check if your slash is back...

    I spent about an hour trying to figure out what's wrong with SERVER/INSTANCENAME when everything is configured correctly, named pipes, user access rights... and suddenly it struck me, it's not a slash, it's a backslash (\).

    The horror, the shame...

    0 讨论(0)
  • 2020-11-22 09:05

    I struggled for ages on this one before I realized my error - I had used commas instead of semicolons in the connect string

    0 讨论(0)
  • 2020-11-22 09:06

    I was trying to add a new connection in VS2015. None of the suggestions here worked. Suspecting some sort of a bug in the wizard, especially since SSMS was able to connect just fine, I decided to try and trick it. It worked!

    1. Instead of adding the connection, use "Create new SQL Server Database". Enter your server name and a random name for the new DB, e.g. "test".

    2. Assuming this succeeds, open Server Explorer in VS, locate the connection in Data Connections, right-click it and select Modify Connection.

    3. Change "test" (from step 1) to the name of the existing database you want to connect to. Click "Test Connection". This time it should work!

    4. Delete the temporary database you created in step 1.

    0 讨论(0)
  • 2020-11-22 09:07

    i Just enabled TCP/IP,VIA,Named Pipes in Sql Server Configuration manager , My problem got solved refer this for more info Resolving Named Pipes Error 40

    0 讨论(0)
提交回复
热议问题