views:

61

answers:

1

Hi. I'm developing an ASP.NET application that is connecting to a SQL Server database using a sql account ie a connection string in the format "Server=THESQLSERVER;Database=theDb;UID=guest;PWD=guest;". Everything works fine in the development environment in Visual Studio. However when I publish the application to my IIS (v5.0) webserver I get the 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).

Funny thing is that doing exactly the same for a different server works fine when the application is published.

Can anyone provide any pointers or links that might explain this behaviour. I've done some searching around, but can't find anything that obviously relates to the problem. Please don't kill yourselves on this one as this is not a deal-stopping problem. I'm just mighty curious. Thanks. David

+2  A: 

Well that's one of them near useless errors we see alot.

The easiest options are to check that the SQL Server actually does allow remote connections. Second try connecting from Management Studio from the PC where the site is deployed. Try a couple of users as well. When doing so make sure you use the server name in the config and also try using the ip address.

Robert
Perhaps I didn't make it clear that the site is presently being hosted on my dev machine. So the connection works when debugging in Visual studio on my box, but fails when published to the dev machines IIS website. Connection is fine from Management Studio as expected. Would it be anything to do with the NT account that IIS is running under? That's all I can think of for now. David
Indeed publishing into IIS does run the site under the context of a different user.You could go to IIS and under directory security untick the allow anonymous user and tick integrated security.Or alternatively change the anonymous username and password to a user that does have permission to connect to SQL Server.Finally you can grant the anonymous user account permission to connect to SQL Server.
Robert