【发布时间】:2015-12-11 16:56:25
【问题描述】:
我无法使用以下代码连接到现有的 MDF 文件:
conn = new SqlConnection("Data Source=(LocalDB)\\v11.0;" +
"Integrated Security=True;" +
"AttachDbFilename=" + Path.GetFullPath("Database.mdf") + ";");
conn.Open();
无论我尝试什么,我都会收到以下错误:
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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.)
【问题讨论】:
-
看起来您的 sql server 实例可能没有运行。您是否验证该服务正在运行?
标签: c# wpf database-connection