Can't connect to database from file

匿名 (未验证) 提交于 2019-12-03 02:33:02

问题:

I try to connect through: Microsoft SQL Server Database File (SqlClient), but I recieve error:

The attempt to attach to the database failed with the following 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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)

So, i click Connect to Database in Server Explorer

This window show up. In which i choose: Microsoft SQL Server Database File (SqlClient) and then browse my .mdf database file.

Clicking ok gives error mentioned before:

Server is running, I use windows authentication in database. Any sugestions?

回答1:

You need the SQL Server Express LocalDB add-on, you can get it from here in both x86 & amd64 versions.



回答2:

I had faced same issue when I deployed my software on test machine.
Solution:

  1. Check the SQL server version using which the .mdf was build. If you don't know execute command SELECT @@VERSION.
  2. Install correct version of SqlLocalDB.msi from following link.
    http://www.microsoft.com/en-us/download/details.aspx?id=29062 http://www.microsoft.com/en-my/download/details.aspx?id=42299.


回答3:

Try to use SQL Server Authentication. Make sure that your SQL service is running or not. I think this will help you.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!