Point to localhost\sqlexpress using only localhost
Asked Answered
R

3

28

Working on a common codebase, one developer is running SQL Server Express 2005 and the other 2 are running SQL Server 2005. Everything is working fine, but the connection strings differ. To maintain common configuration and build scripts we're looking to mask "localhost\sqlexpress" to just "localhost" like the other 2 developers.

Can this be done? Or, maybe there's a better way for all 3 to run on the same connection string... The solution sought is for all 3 to be able to run on the same file versions in the code repository.

I might not be 100% clear: basically I want this:

Data Source=localhost;Initial Catalog=Sample;Integrated Security=True

to connect the exact same as this:

Data Source=localhost\sqlexpress;Initial Catalog=Sample;Integrated Security=True

If at all possible.

Raeraeann answered 16/1, 2009 at 5:40 Comment(0)
A
59

Just tested things out and got it working.

sql express doesnt enable tcp/ip by default and when enabled doesnt use the default port 1433.

to make this happen you need to open up "Sql server configuration manager" then under protocols enable tcp/ip. after that double click "tcp/ip", select the "IP Addresses" tab and scroll to the bottom then blank the "TCP Dynamic Ports" and enter 1433 under TCP Port.

after all that restart the sql server service and it should work with the normal connection string.

Allister answered 16/1, 2009 at 6:16 Comment(1)
Thanks John - and thanks to your evil monkey too. An additional problem that I had was that the service. "SQL Server Browser" Was not running. It allows for outside connections.Ellison
S
0

You can name SQL Server instances to anything you want. I'm pretty sure you can do it in SQL Express as well, so just name the instance, on each machine, to the same name, then you can just use localhost\<name>.

Or even better, don't hardcode the database name. Load it from some machine or user-specific setting (registry, config file, whatever suits your fancy :) ).

Skidproof answered 16/1, 2009 at 5:53 Comment(0)
S
0

This topic is dead and buried, I'm sure... But incase this also helps someone:

"one developer is running SQL Server Express 2005 and the other 2 are running SQL Server 2005"

When they installed, chances are the instance was named MSSQLSERVER. When you installed, chances are the instance was named SQLEXPRESS. MSSQLSERVER works as localhost out of the box, SQLEXPRESS does not. You can get round this in SQL Server Express by renaming SQLEXPRESS to MSSQLSERVER on install, for future reference.

John's solution is obviously cleaner.

Superhuman answered 11/11, 2013 at 20:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.