2017-09-22 103 views
0

我在运行时出现此错误:连接到在C#中的Microsoft SQL Server失败

Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

enter image description here

+1

为什么你连接到SSMS在C#中?难道你不直接连接到数据库?似乎你的问题与SSMS毫无关系。 – mason

+0

谷歌错误消息,或在这里搜索它。这个问题在此之前已经被询问过(并回答过)很多次。发布它再一次没有意义,因为捕获整个屏幕来描述文本错误消息。 –

+0

那么,你准确地提出了什么? –

回答

0
  1. 你需要尝试使用SSMS连接到数据库LibraryDB
  2. 您的连接字符串Data Source格式错误且语法不正确。 LocalDB名称后永远不会有HashTag。
  3. 您最好使用.(LocalHost)在您的计算机上运行数据库服务器,否则您需要将驱动程序更改为SqlServer以外的其他驱动程序。

读盘:https://blogs.msdn.microsoft.com/sql_protocols/2008/09/19/understanding-data-sourcelocal-in-sql-server-connection-strings/

+0

非常感谢。 –