0

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.

jrev
  • 33
  • 4

2 Answers2

2

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.

jrev
  • 33
  • 4
0

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

Eric Labashosky
  • 29,484
  • 14
  • 39
  • 32
  • I don't think this answer addresses having two PCs connected to the same mdf file located on a server share. That's something you can do with Access mdb files but doesn't sound possible with LocalDB. – Mike Lowery Feb 05 '19 at 03:39