cycero
cycero

Reputation: 4761

SQL server name in hosts file

I'm developing an ASP.NET application and we're using TFS for source control. Each time we need to change the "data source" in the connectionString to point to our local server during the development. I'm running SQLEXPRESS so I was writing .\SQLEXPRESS in the web.config file and it was working fine. Now we shouldn't modify the web.config file any more and will need to add a record into the hosts file to point the "data source" from the web.config file to my local machine's SQL server. Say, we have "DEVDATABASE" in the web.config as "data source", how should the hosts file line look like for that to work? Something like the following?

.\SQLEXPRESS DEVDATABASE

This however does not work. Could anybody please help me to understand what's the way it should work?

Thanks.

Upvotes: 2

Views: 12432

Answers (1)

Aaron Bertrand
Aaron Bertrand

Reputation: 280431

You can't use the hosts file (or DNS) to point at a named instance. This is meant to redirect only to a specific machine, not to a specific machine + port number. You could try creating an alias in the client network utility - you'll also want to make sure that TCP/IP is enabled and that the SQL Browser service is running.

Upvotes: 4

Related Questions