mercoledì 15 aprile 2020

Database 'NomeDatabse.MDF' cannot be upgraded because it is read-only, has read-only files or the user does not have permissions to modify some of the files. Make the database or files writeable, and rerun recovery.

Quando si rilascia un progetto, o meglio applicativo che fa uso del database Sql Server con uso di file .mdf può capitare di visualizzare il messaggio qui di seguito quando si esegue il nostro programma.

Database 'NomeDatabse.MDF' cannot be upgraded because it is read-only, has read-only files or the user does not have permissions to modify some of the files. Make the database or files writeable, and rerun recovery.


e continuando con

An attempt to attach an auto-named database for file NomeDatabase.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. LOAD.

In questo caso il database è contrassegnato come sola lettura.

Per risolvere questo problema, aprite il Management di Microsoft Sql Server, in modalità "Amministratore" e dalla voce "Database" fate click con il tasto destro e poi "collega" al database che presenta questo problema.

Dopo averlo aggiunto, fate click sul pulsante "Nuovo query" e digitate il seguente comando

USE [master]
GO
ALTER DATABASE [NomeDatabase.MDF] SET  READ_WRITE WITH NO_WAIT
GO

A questo punto eseguite la query.

Da ricordare che il parametro "NomeDatabase.mdf" è quello che vedete visualizzato in Sql server, potete fare anche tasto destro sul nome del database, e dal menu che viene visualizzato selezionare la voce "Proprietà" e vedere la voce "Nome Database".

A questo punto il database non è più di sola lettura.



Nessun commento: