Point to localhost\\sqlexpress using only localhost

青春壹個敷衍的年華 提交于 2019-11-28 17:15:58

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.

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 :) ).

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!