07-31-2023, 09:58 AM
I had this issue when I try to backup a database.
System.Data.SqlClient.SqlError:
Cannot open backup device 'C:\x\x\xxx.bak'.
Operating system error 5 (Access is denied.). (Microsoft.SqlServer.Smo)
When I had this issue I thought that the user which I'm connecting to database don't have rights to access to the backup location. I gave full control to that user but nothing changed. This is because the service for SQL Server is running with another user.
[![enter image description here][1]][1]
At this point you may choose changing user of the service to local system account or add access rights for the current user of the service.
I choose the 2nd one.
[![enter image description here][2]][2]
After that change backup succeeded.
[1]:
[2]:
System.Data.SqlClient.SqlError:
Cannot open backup device 'C:\x\x\xxx.bak'.
Operating system error 5 (Access is denied.). (Microsoft.SqlServer.Smo)
When I had this issue I thought that the user which I'm connecting to database don't have rights to access to the backup location. I gave full control to that user but nothing changed. This is because the service for SQL Server is running with another user.
[![enter image description here][1]][1]
At this point you may choose changing user of the service to local system account or add access rights for the current user of the service.
I choose the 2nd one.
[![enter image description here][2]][2]
After that change backup succeeded.
[1]:
[2]: