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

Posted on 2008-11-10
Last Modified: 2012-05-05
I have a new application that is connecting to SQL 2005. Every time I run I get the following error:
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)

Application is running on an XP box. SQL 2005 is developer edition running on the same box.
The funny thing is that if I run a different application and point it to the same database everything works fine. The code that access the database is the same on both applications.
I have never had any problem getting to SQL on any other application. I have verified that the connection string is correct. The new application also referenced Oracle client, so I thought that might be a problem. I remove all references to the Oracle client and the app still fails.

Any help would be appreciated. This has been haunting me for 2 days.
Question by:ndingle
    LVL 7

    Accepted Solution

    Applications can use different connection strings.
    Could you compare them? do you use Windows Authetification or provide user/password to connect SQL?

    Also, try disable Named Pipes and Enable Shared Memory and TCP/IP.

    Author Comment

    The connection strings are the same in both applications. This has been verified in debugger. I am using SQL authentication for both applications.

    I am not sure how to disable named Pipes, but will give it a try.

    Author Comment

    I enabled TCP/IP and shared memory, disabled named Pipes. Still have the problem.
    LVL 7

    Expert Comment

    You have Accepted soluton - but still have a problem?

    Do you guarantee both connection strings are 100% equal?
    Maybe, one use (local) as server, and second PCNAME?

    Do you see: (provider: TCP/IP Provider, error: 40 - Could not open a connection to SQL Server)?

    Try write "PCNAME,1433"  (this will force to use TCP/IP with specified port)


    Author Comment

    I did not get the Named pipes turned off as I thought. It solved the problem

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Introduced in Microsoft SQL Server 2005, the Copy Database Wizard ( is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
    I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
    Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now