2014-12-29 178 views
-4

我使用这个连接字符串为我的项目:连接字符串错误

Server=.\\SQLExpress;AttachDbFilename=D:\\Database.mdf;Database=Database;Trusted_Connection=Yes;user instance=true; 

,但执行时,我的程序得到了一个错误:

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)

+2

你DATABSE名称是“数据库”这是我见过最糟糕的数据库名称:) – Mehmet

+0

该文件是否存在于D:\\磁盘中?同时检查文件是否存在访问问题 - 检查权限。 – msporek

+0

是这个'\\ SQLExpress'就是你的实例名称 –

回答

1

请检查您的SQL Server Browser服务正在运行通过使用SQL Server配置管理器,并请检查网络协议按如下图: enter image description here

0

可能是MSSQLSERVER服务Component ServiceAdministrative Tools是不工作。请检查。如果不是那么你能登录你的SQL Management Studio(如果有)?