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

前端 未结 30 2541
借酒劲吻你
借酒劲吻你 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:24

    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.

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

    For me it was a Firewall issue.

    First you have to add the port (such as 1444 and maybe 1434) but also

    C:\Program Files (x86)\Microsoft SQL Server\90\Shared\sqlbrowser.exe
    

    and

    %ProgramFiles%\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\Binn\SQLAGENT.EXE
    

    The second time I got this issue is when I came back to the firewall, the paths were not correct and I needed to update form 12 to 13! Simply clicking on browse in the Programs and Services tab helped to realise this.

    Finally, try running the command

    EXEC xp_readerrorlog 0,1,"could not register the Service Principal Name",Null

    For me, it returned the error reason

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

    Thanks to Damian...

    TCP/IP Named Pipes ... both enabled

    Web Config....(for localhost)

    <add name="FooData" connectionString="Data Source=localhost\InstanceName;Initial Catalog=DatabaseName;Integrated Security=True;" providerName="System.Data.SqlClient" />
    
    0 讨论(0)
  • 2020-11-22 09:25

    I have suggested below steps to resolve your issue How do I fix the error 'Named Pipes Provider, error 40 - Could not open a connection to' SQL Server'

    1. Check for working fine SQL Server Services services or not.
    2. Also check for working in good condition SQL Server (MSSQLSERVER).
    3. Also check for working fine SQL Server Browser.
    4. Delete all earlier Aliases, now create new aliases as per your requirements.
    5. Now check for working of SQL Server Default Port 1433
    6. Next click on Client Protocols in instance, then click on TCP/IP, now click on mouse right click, open the Property, here you can make assure your working fine your default port SQL 1433.
    7. Open your SQL Server Management Studio, then right click, click on "Property" option and then click on Connections tab, then finally tick for Allow remote Connections to this server.
    8. Check for right working or your Ping IP Host.
    0 讨论(0)
  • 2020-11-22 09:27

    I have one more solution, I think. I recently had changed my computer name so, after I couldn't connect still after trying all above methods. I changed the Server name.. Server name => (browse for more) => under database engine, a new server was found same as computers new name. This worked, and life is good again.

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

    Very simple solution

    use (local)\InstanceName that's it. it worked for me.

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