简体   繁体   English

SQL Server连接-为什么(本地)不起作用,但是本地主机起作用

[英]SQL Server Connections - Why (local) doesn't work but localhost does

Currently have an application trying to connect to (local) as a data source in .NET. 当前,有一个应用程序试图连接到.NET中的数据源(local) For some reason (local) isn't working, but localhost is working. 由于某些原因, (local)不起作用,但是localhost正在起作用。

I'm not using a named instance, directly replace (local) with localhost is cause the application to successfully connect. 我没有使用命名实例,直接用(local) localhost替换(local)会导致应用程序成功连接。

Any ideas why this might be? 任何想法为什么会这样? I understand (local) is a keyword but it should work exactly like localhost should it not? 我知道(local)是一个关键字,但是它应该像localhost一样正常工作,不是吗?

I've tried the connection from SQL Server Management Studio, and I can successfully connect using localhost or . 我已经尝试了从SQL Server Management Studio进行连接,并且可以使用localhost或成功连接. but not (local) . 但不是(local)

"(local)" could be just an alias for 'localhost'. “(本地)”可能只是“本地主机”的别名。

While in SQLServer, '(local)' and '.' 在SQLServer中,为“(local)”和“。”。 mean that the connection will be made using the named pipes (shared memory) protocol within the same machine 表示将使用同一台机器内的命名管道(共享内存)协议建立连接

Localhost is an IP address where to find the server. Localhost是可在其中找到服务器的IP地址。 All communication goes over TCP at the address 127.0.0.1 Local is sql server specific. 所有通信都通过TCP在地址127.0.0.1上进行。本地特定于sql server。 The communication will not use TCP but something like named pipes. 通信将不使用TCP,而是使用诸如命名管道之类的东西。

As it looks the different versions of your connectionstring lead to a different communication protocol between client and sql-server. 从外观上看,连接字符串的不同版本导致客户端和sql-server之间的通信协议不同。 Which leads to different behavior. 这导致了不同的行为。

Try reinstalling and ensure to select "default instance" instead of "named instance" during the installation. 尝试重新安装,并确保在安装过程中选择“默认实例”而不是“命名实例”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM