Click to See Complete Forum and Search --> : [RESOLVED] problems connecting to database from web app


fogofogo
09-19-2007, 10:18 AM
Hello all,

I'll try to explain this as clearly as possible, so apologies if its not.

I am having a database connection problem with an application I have made. The site files are on one web server, and the database sits on a different server. I'm using sql server and asp.net(c#)

When I test the site on the live web server, I get the following error message...


Server Error in '/' Application.

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)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: 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 get the above error using the follow config file

<?xml version="1.0"?>

<configuration>
<appSettings/>
<connectionStrings>

<remove name="LocalSqlServer" />
<add name="cashinsConnectionString" connectionString="Data Source=SERVER IP ADDRESS;Initial Catalog=ffgty123; Persist Security Info=True; User ID=USER HERE; Password=PASSWORD HERE" providerName="System.Data.SqlClient"/>

</connectionStrings>
<system.web>

<compilation debug="true"/>

<authentication mode="Forms"/>

<customErrors mode="Off"/>
</system.web>
</configuration>


I pass the connection into datasets, and into classes that I have stored in a .cs file, for use through out the application.

Heres the strange part, If I run the application from visual developer, using my local host, its connects fine. So Why does it work on my machine and not the webserver? I also created a basic page that was able to connect to the database from the webserver using the same string as above.

So what could I be doing wrong? I dont understand how my application could connect to the database server from my machine and not the webserver.

Any help would be greatly appreciated

Thanks

fogofogo
09-19-2007, 11:22 AM
fixed