Trouble connecting to SQL Server 2005 from ASP.Net Web App

  • We set up a second database server which will need to be accessed from the internet via asp.net applications. (as did the first database server) When I switched the connection string in the application to point to the new database server it cannot establish a connection. When I run the application in Visual Studio 2005 using localhost (on my machine) it accesses database server #2 just fine. But from the Web server it gives this error:

    Exception: System.Data.SqlClient.SqlException: 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)

    I made sure SQL Server #2 allows remote connections via TCP/IP on port 1433. (same as SQL Server #1)

    I made sure with the network guy that the firewall is allowing server #2 and the port 1433 (and 1434).

    I made sure all three servers have the same local account and that the SQL Server service on both database servers use this account. The user (webuser) and password in the connection string in the application is set up the same on both database servers (in SQL Server user logons). webuser is not setup as a local account on server #1 so I didn't think it was needed on server #2, it is just a SQL Server logon.

    I made sure the account being used by Anonomous user is also an account on the database server #2 (as it is on #1)

    I tried switching the port for #2 to 1434 and that didn't help so I switched it back.

    I tried switching from Anonomous logon in IIS to Basic authentication and that produced the same results so I switched it back.

    I am running out of ideas and google queries. HELP!

  • try port 1254

  • maybe as a place to start, try this to check named pipes (which was in error message).  From Books Online  (named pipes).  Good luck.

    Named Pipes

    Client Connections

    The following procedure describes how to test a network connection when using Named Pipes as the IPC mechanism.

    To test a Named Pipes connection

    • At the operating-system command prompt on the client workstation, type:

      net view \\servername

    When using net view, servername is the name of the server to which you want to connect.

    For example, to check the connection between a Named Pipes client and a server named \\SEATTLE1, type the following on the client:

    net view \\SEATTLE1

  • First of all make sure all protocals are enabled in SQL Server 2005.

    Then see if you can telnet from the remote server to the DB server using ports 1433/1434.  Try from another machine as well.  Might be some weird fw rule preventing you from getting through

    Also are you using Web.config or machine.comfig?  If you made changes to the connection string in machine.config and you have a diff connection string in the web.config - the web.config will be used.  Just something to check.

  • Thanks for all the above input.  I did fix the problem.  It was a DNS problem.  As soon as I entered in the IP address into the connection string like 10.xx.xx.xx instead of the name, the connection to the database worked.

Viewing 5 posts - 1 through 4 (of 4 total)

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