Err connecting to SQL 2000 from VS 2005

Posted on 2007-10-14
Last Modified: 2013-11-26
I'm trying to connect to an SQL Server 2000 DB from VS 2005 through Server Explorer -> Add Connections. I'm getting the following error for that :

An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

though i've SQL Server 2000 running locally on my machine. & why is it connecting to SQL Server 2005, i want it to connect it to SQL Server 2000.

Any idea about this one.

Thanks in advance.
Question by:kapiljoshi
    LVL 48

    Expert Comment

    Are you using the right connection string ? Show us your code.


    Author Comment

    My Web.config
    has the following entry

        <add key="ConString" value="Data Source=(localhost);Initial Catalog=NorthWind;User ID=sa;Password=kj"/>

    My code behind .vb file has the following code
    If Conn.State = ConnectionState.Open Then
    End If

    Conn.ConnectionString = ConfigurationManager.AppSettings.Item("ConString").ToString
    Conn.Open() --Err @ this line

    Even without the code, if I try to create a connection from the Server Explorer using DataConnections -> Add Connection ... , I get the same error

    LVL 48

    Expert Comment

    If you want to connect to SQL Server you have to change your connection string, not using localhost.

    Have a look on this examples:

    Accepted Solution

    I got the problem . the problem was not with the format of Connection string.

    I was trying to connect with Machinename.
    I was not specifying the Instance name of SQL Server i.e. Data Source=Machinename\SQL Server Instance Name

    Thanks for the link though. Can i close this thread as self answered.

    LVL 48

    Expert Comment

    You can go to this link and ask to delete this question

    Author Comment


    LVL 1

    Expert Comment

    Closed, 125 points refunded.
    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    Flash ( has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    761 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

    14 Experts available now in Live!

    Get 1:1 Help Now