C# Sql 连接无法连接到服务器

C# Sql Connection can not connect to server

我正在尝试使用以下连接字符串连接虚拟机中的 SQL 服务器:"Server=qqvm;Database=a_test;Integrated Security=False;User Id=sa;Password=<pass>;Connect Timeout=0"

首先,我有 'Network connection' 异常,内部 'Access Denied' 异常,堆栈跟踪为空。我做了一些挖掘并在 SQL 配置管理器中启用了 'Named Pipes'。 之后我得到了这个例外:

Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=11281; handshake=1;

但是,我仍然可以通过 SQL Management Studio 远程连接到该服务器。有什么想法吗?

最后,在我的例子中,指定 IP 地址而不是 qqvm 名称解决了问题。不过,仍然不知道为什么。它在一周前工作。