【发布时间】:2014-01-23 20:18:38
【问题描述】:
根据我学到的here,我正在使用这个连接字符串:
using (var conn = new SqlConnection(@"AttachDBFilename=C:\HoldingTank\AdventureWorksLT2012_Database\AdventureWorksLT2012_Data.MDF;Integrated Security=True;User Instance=true"))
...to(尝试)附加到本地 SQL Server 数据库,但我在运行时收到此异常:
System.Data.SqlClient.SqlException was unhandled by user code
HResult=-2146232060
Message=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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Source=.Net SqlClient Data Provider
根据我的旧版 MS Access 连接字符串,我之前也有:
Provider=System.Data.SqlClient;
在连接字符串的“AttachDBFilename=...”部分之前,但这导致了它自己的异常...
【问题讨论】:
标签: sql-server tsql connection-string named-pipes sqlclient