Concurrent use of LocalDB on a network drive(s)

北城以北 提交于 2019-12-12 01:16:09

问题


My configuration is as follows:

Server with Z: mapped to d:\something

Client with Z: mapped to \\server\ A LocalDB MDF (and the whole application) located at Z:

Either computer alone is OK, but doesn't work simultaneously. I get an exception saying System.Data.SqlClient.SqlException 0x80131904 Cannot open database z:\xxx\xxx.mdf requested by the login. the login failed.


回答1:


This cannot be done. SQL requires than physical file attached to the database should be opened exclusively by the engine.

Solved by installing SQLEXPRESS which supports remote connections.




回答2:


This can be done. But it's not easy (did this with SQL 2016 localdb).

  1. create the database locally. The database will be created in C:\Users\ eg c:\Users\eric\database.mdf
  2. Close SSMS (or disconnect from the object explorer)
  3. from a command prompt: MSSQLLocalDB stop
  4. move the database.mdf & database_log.ldf to a network drive (eg s:\sql\database.mdf).
  5. create symbolic links from the original location to new location. From a command prompt: mklink c:\Users\eric\database.mdf s:\sql\database.mdf mklink c:\Users\eric\database_log.ldf s:\sql\database_log.ldf

  6. MSSQLLocalDB start



来源:https://stackoverflow.com/questions/12107158/concurrent-use-of-localdb-on-a-network-drives

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