Unable to update database .MDF is Read Only

前端 未结 5 1819
感情败类
感情败类 2021-01-14 10:44

I have a local DB that I have in an application. When I install it on another machine I get the error

Unable to update database.. .mdf is read only.<

相关标签:
5条回答
  • 2021-01-14 11:01
    1. Just go to the program files and find the folder of the installed program.
    2. Just right click the .mdf file in the folder and click PROPERTIES.
    3. In PROPERTIES TAB -> SECURITY -> you'll see Group or Usernames.
    4. In that select the User to which u want to give Access to the file.
    5. If for that user the PERMISSION is not set to FULL CONTROL.
    6. TO CHANGE PERMISSIONS -> CLICK EDIT.
    7. Now the Group or Username box will open.
    8. In that Select The User -> Select FULL CONTROL in Permission Box.
    9. Now follow the steps for the log file too. IF Needed.

    OR

    Just install your application in different folder other than ProgramFile(x86)

    0 讨论(0)
  • 2021-01-14 11:01

    I solved the same problem as follows:

    While creating "Setup", I manually added my database files database.mdf and database_log.ldf into the Application Folder file. But after adding these files, make sure that the ReadOnly option in the Properties section is False.

    Also "connectionString" I use:

    connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;Connect Timeout=30" 
    
    0 讨论(0)
  • 2021-01-14 11:05

    First stop the SQLEXPRESS service from local-Services menu and then try to move and connect the database again by attaching database option in SQLEXPRESS. it should work. it works for me. :)

    0 讨论(0)
  • 2021-01-14 11:11

    if your database file on the C volume, try to move the .mfd file to D volume

    0 讨论(0)
  • 2021-01-14 11:22

    The MDF file would be readonly either because the readonly file attribute flag is set, in which case you have to unset it, or another program has the MDF file locked as readonly. Are you running a version of SQL server that is using that file?

    I've never seen a connection to the MDF file directly, usually it's done via the server, and the server will manage all the IO for the MDF file.

    E.g. a typical connection string for SQL Server:

    Database=<dbname>;Server=<servername>;MultipleActiveResultSets=True;Connection Timeout=10;User Id=<username>;Password=<password>;
    

    Additional links:

    1) Failed to update .mdf database because the database is read-only (Windows application)

    2) Failed to update database because it is read-only

    3) Failed to update database "*.mdf" because read only EntityFramework

    4) http://www.codeproject.com/Questions/183758/Failed-to-update-mdf-database-because-the-database

    0 讨论(0)
提交回复
热议问题