Thursday, February 16, 2012

Can''t connect to SQL Express or SQL 2005 from C# web app and IIS

Hi all,

I'm new to this forum and haven't worked with SQL Server for a couple of years. Now it seems I'm getting back into it. I have SQL Express and SQL 2005 installed on an XP sp2 machine with IIS 5.1. I have a C#/ASP.NET web app in Visual Studio 2005 that keeps getting an error on attempting to connect (SqlConnection object). It's a generic error saying a probable cause is SQL Express default setup not allowing remote connections. Remote connections are turned on for both TCP and UDP. I can connect from within a small C# windows application using the same uid and pwd, so I suspect it's something related to IIS talking to SQLExpress. I would appreciate any help on other things to check. I am also fairly new to using IIS in the development environment.

Thanks

It could be because you didn't specify the instance name when you tried to connect from the C# app? It could also be that SQLBrowser isn't running.

Hope that helps,

John

|||

This is because SQL Server 2005 Express Edition does not accepts remote connections by default:

How to: Enable Network Access During Installation of SQL Server 2005 Express Edition

|||

Thanks John,

Yes, I specified the instance name and verified SQLBrowser is running. COnnection string = "Server=BUTTERFLY\SQLExpress; Initial Catalog=catalog; uid=username; pwd=password;

|||

Ronald,

Thanks for pointing me to this information. It didn't actually solve my dilemma, but it did get the juices flowing. This is related to a project I inherited and upgraded from .NET 1.1 to 2.0. The sql connection string referenced a property for "server=", changing this to "data source=" allowed the connection to open properly. I am reading the links you pointed and they are very helpful. Thanks

No comments:

Post a Comment