How do I fix the error 'Named Pipes Provider,

2019-01-01 08:19发布

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

I tried using the local IP address to connect as well as a public one. I've tried:

  1. Yes, the site can communicate with the server
  2. Named pipes/TCP is enabled.
  3. Remote connections are allowed.
  4. Windows Firewall is off
  5. Created an exception for port 1433 in Windows Firewall.
  6. Enabled everything in SQL Server Configuration Manager.

What else can I do here?

27条回答
美炸的是我
2楼-- · 2019-01-01 08:56

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.

查看更多
宁负流年不负卿
3楼-- · 2019-01-01 08:56

I had this issue but none of the suggestions above fixed it.

I was seeing this issue when I deployed my website to IIS. The fix was to go into advanced settings against the default app pool and change the identity property from the default to Administrator.

查看更多
初与友歌
4楼-- · 2019-01-01 08:57

Enable TCP/Ip , Piped Protocol by going to Computer Management ->SQL and Services, ensure the Service is On. Enbale the port on the Firewall. Try to login through Command Prompt -> as Admin; last the User Name should be (local)\SQLEXPRESS. Hope this helps.

查看更多
情到深处是孤独
5楼-- · 2019-01-01 08:58

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

查看更多
时光乱了年华
6楼-- · 2019-01-01 08:59

It's a three step process really after installing SQL Server:

  1. Enable Named Pipes SQL Config Manager --> SQL Server Network Consif --> Protocols --> Named Pipes --> Right-click --> Restart

named pipes enabled

  1. Restart the server SQL Config Manager --> SQL Server Services --> SQL Server (SQLEXPRESS) --> Right-click --> Restart

  2. Use proper server and instance names (both are needed!) Typically this would be .\SQLEXPRESS, for example see the screenshot from QueryExpress connection dialog.

enter image description here

There you have it.

查看更多
千与千寻千般痛.
7楼-- · 2019-01-01 09:01

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

查看更多
登录 后发表回答