Permission denied is a security so you need to add a “User” permission..
- Right click you database(which is .mdf file) and then properties
- Go to security tab
- Click Continue button
- Click Add button
- Click Advance button
- Another window will show, then you click the “Find Now” button on the right side.
- On the fields below, go to the bottom most and click the “Users”. Click OK.
- Click the permission “Users” that you have been created, then Check the full control checkbox.
There you go. You have now permission to your database.
Note: The connection-string in the above questions is using SQL-server authentication. So, Before taking the above step, You have to login using windows-authentication first, and then you have to give permission to the user who is using sql-server authentication. Permission like “dbcreator”.
if you login with SQL server authentication and trying to give permission to the user you logged in. it shows, permission denied error.