简体   繁体   中英

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. For some reason (local) isn't working, but localhost is working.

I'm not using a named instance, directly replace (local) with localhost is cause the application to successfully connect.

Any ideas why this might be? I understand (local) is a keyword but it should work exactly like localhost should it not?

I've tried the connection from SQL Server Management Studio, and I can successfully connect using localhost or . but not (local) .

"(local)" could be just an alias for 'localhost'.

While in SQLServer, '(local)' and '.' 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. All communication goes over TCP at the address 127.0.0.1 Local is sql server specific. The communication will not use TCP but something like named pipes.

As it looks the different versions of your connectionstring lead to a different communication protocol between client and sql-server. Which leads to different behavior.

Try reinstalling and ensure to select "default instance" instead of "named instance" during the installation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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