3

Running SQL Server LocalDB 2012 and 2014 on Windows Server 2008 R2 SP1 VM I have some bizarre issues which don't happen when running on Windows 7 or Windows 10.

I can create databases, save data to them, but then after a few minutes the database .mdf file seems to lock. I get the error (in my c# code)

Failed to update database "dbname" because the database is read-only.

I have ruled out any other application locking the database file. It seems to be an SQL Server issue, so far as I can determine.

I tried opening the database in Management Studio, it tells me the db is read only. It also cannot change the status, throwing a 5 (Access is denied) error (5120)

SQL Management Studio Error

I can confirm that the database file (mdf) is not write protected - I can rename the file, or open and change it in HxD, for example. If I copy the database files to another computer, it works fine. No permissions or write issues.

SQL can't edit it, and I don't know why. What might be causing this?

Sugrue
  • 173
  • 1
  • 9

1 Answers1

2

It's hard to say for certain, but I would check the following things:

  1. SQL Express is limited to databases 10 GB or smaller. Has your database grown to a size larger than that?
  2. But based on the error message: Does the SQL Service Account have full access to the directory where the database lives? Does the SQL Service Account have full access to the file?
  3. Is there perhaps a security program that needs to have this database listed under exceptions?
Katherine Villyard
  • 18,550
  • 4
  • 37
  • 59
  • Thanks for your reply. Some answers: 1) no - the db file is the same size as when it was created minutes earlier - 128Mb 2)The odd thing is - it definitely did have access when it created the db file, but about 3 minutes later it loses access (I've tried this around 15 times). I have no idea why. 3) maybe - I'll investigate. Thanks again. – Sugrue Oct 17 '18 at 08:25