[newbie] An error has occurred while establi shing a connection to the server.

  • I'm trying to use sqlcmd, however, I'm getting the following error:

    1st error...

    C:\Program Files\Microsoft Visual Studio 9.0\VC>sqlcmd -d master -U sa -P passwo

    rd

    HResult 0x2, Level 16, State 1

    Named Pipes Provider: Could not open a connection to SQL Server [2].

    Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establi

    shing a connection to the server. When connecting to SQL Server 2005, this failu

    re may be caused by the fact that under the default settings SQL Server does not

    allow remote connections..

    Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.

    So far I've checked that SQL Server browser service is running.

    I've searched high and low going but found no solutions so far.

    :w00t:

    Related links:

    http://www.codeproject.com/script/Forums/View.aspx?fid=1642&msg=2958694 - forum post

    http://forums.asp.net/t/939300.aspx - 2nd error

  • Have you checked to make sure that the SQL Server has Named Pipes enabled? YOu can check this using the SQL Server Configuration Manager under Network Configuration.

  • I enabled it, and, restarted the SQL Service and SQL Service Browser, but no joy.

  • Can you connect to the server using another application like SSMS?

  • yep

  • Are you using trusted connection to login to the server? you can use -E if yes.

  • apat (3/13/2009)


    Are you using trusted connection to login to the server? you can use -E if yes.

    Still a time out error though...

    Microsoft Windows XP [Version 5.1.2600]

    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\Jonathan>sqlcmd -E -d master

    HResult 0x2, Level 16, State 1

    Named Pipes Provider: Could not open a connection to SQL Server [2].

    Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establi

    shing a connection to the server. When connecting to SQL Server 2005, this failu

    re may be caused by the fact that under the default settings SQL Server does not

    allow remote connections..

    Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.

    C:\Documents and Settings\Jonathan>

  • Can you connect using tcp? You can force sqlcmd to connect using tcp like this:

    sqlcmd -E -Stcp:yourservername[,port if not default]

  • Still no joy.

    I also checked/updated the following, from SQL Server Configuration Manager:

    SQL Server 2005 Network Configuration > Protocols for SQLEXPRESS

    Shared Memory - Enabled

    TCP/IP - Enabled (updated because it was disabled)

    VIA - Disabled

    SQL Native Client Configuration > Client Protocols

    Shared Memory - Enabled

    TCP/IP - Enabled

    Named Pipes - Enabled

    VIA - Disabled

    Microsoft Windows XP [Version 5.1.2600]

    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\Jonathan>sqlcmd -E -Stcp:armani

    HResult 0x274D, Level 16, State 1

    TCP Provider: No connection could be made because the target machine actively re

    fused it.

    Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establi

    shing a connection to the server. When connecting to SQL Server 2005, this failu

    re may be caused by the fact that under the default settings SQL Server does not

    allow remote connections..

    Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.

    C:\Documents and Settings\Jonathan>sqlcmd -E -Stcp:armani

    HResult 0x274D, Level 16, State 1

    TCP Provider: No connection could be made because the target machine actively re

    fused it.

    Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establi

    shing a connection to the server. When connecting to SQL Server 2005, this failu

    re may be caused by the fact that under the default settings SQL Server does not

    allow remote connections..

    Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.

  • Wait a minute, SQL Server Express? If you take the defaults when installing express it installs a named instance (typically SQLExpress) so you would need to do servername\instancename to connect to it. So try using -Slocalhost\SQLExpress

  • That worked thanks,

    Microsoft Windows XP [Version 5.1.2600]

    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\Jonathan>sqlcmd -E -Stcp:armani -Slocalhost\SQLEXPRESS

    1>

  • Thanks that worked.

    Microsoft Windows XP [Version 5.1.2600]

    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\Jonathan>sqlcmd -E -Stcp:armani -Slocalhost\SQLEXPRESS

    1>

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply