Thursday, February 16, 2012

Can't connect to SQL Express 2005

I have a web app running on a laptop (for demo purposes) with the following connect string:

"datasource=<machine name>\SQLExpress;initial catalog=BlueTarp;User ID=sa;Password=xxx"

I can connect to this instance using both oSQL or sqlcmd and can select from the tables within BlueTarp, but my web app won't connect, and I can't figure out why!!

When I installed SQL Express, I used a named instance, called "SQLExpress".

I'm using mixed mode authentication.

One strange thing is that I can connect to either SQLExpress or MSSQLSERVER instances, but they appear to be the same instance -- I can use bluetarp in both.

when I use SQLExpress for instance name in web.config I get "SQL Server does not exist or access denied"

when I use MSSQLServer for instance name in web.config I get "Invalid connection"

And in fiddling with the web.config, I somehow did something to get a machine.config error, something like "machine.config couldn't be loaded because of an unloaded appdomain".

It's driving me nuts because I've spent a good 40 hours on this stupid problem, throwing the whole margin down the toilet.

Does anyone have any ideas?

Thank you,

Aarron

First, SQL Server has support for multiple protocols for remote connections (shared memory, named pipes, tcp/ip, and via) and if the client is trying a protocol the server has disabled then it will fail to connect.

To see what protocols are enabled, goto Computer Management -> SQL Server Configuration Manager -> SQL Server 2005 Network Configuration -> Protocols for <Instance Name>. If you change the protocols the server supports, you will need to restart the server.

Try using a protocol such as named pipes instead of shared memory. Try np:<machine name>.

http://msdn2.microsoft.com/en-US/library/system.data.sqlclient.sqlconnection.connectionstring(VS.80).aspx

For general troubleshooting of .NET connectivity issues, see this blog entry: http://blogs.msdn.com/sql_protocols/archive/2005/12/22/506607.aspx

For the ASP.NET issue, try restarting IIS/ASP.NET, and make sure machine.config is valid xml with the XML editor in Visual Studio.

|||

Mark,

Thanks so much for your help. I've been all over the web trying to find info about this problem -- people have pointed me to Mcaffe, to the .NET frameworks possibly having issues, to my web.config being poorly formatted.... and it turns out that I wasn't using a supported protocol. I enabled named pipes and it works like a charm.

You da man!

Aarron

No comments:

Post a Comment