locked
Cant restore from backup, script, or copying database on to asp site from localhost or asp project RRS feed

  • Question

  • ​I have tried changing permissions for the database and log file. I have scripted the database out and tried running the script on website (has gotten me further but new errors like Logins don't work once I change connection strings). I'm testing this out on a free domain(small with limited space for my full database so I need to pay for larger space). I tried on GitHubPages with no success. I received same error permissions denied to access database files, backups, or copies? Not sure what I'm doing wrong. Are the properties of my database setup to keep me from doing it? I am running SSMS 2017 developer edition with default settings. I created the database from scratch for a portfolio project with a asp.net website I created to run everything on. My only problem is the database cant be transferred. Even when scripting out and running scripts on remote machine I still receive permissions errors. I have watched countless youtube videos and it seems like everyone else does it with no problems. Im convinced its some sort of database proterty or setting that is keeping any other computer than mine to use the database. I heard there is something called SID's that are written within a database that lets it know if it is on a LocalHost but I am fairly a newb at this. My teacher says its a DBA type question so he couldn't help. What should I do?????????
    Tuesday, February 11, 2020 5:29 AM

Answers

  • Turns out it was hosting issues. They wouldn't give me admin permissions so.... They had to restore database then... They had to rename database so my stored procedures worked... They also had to change the login to said database to work for their systems. So I'm up and running. turns out I did nothing wrong but.... changing files from "read only" to "read/write" did help me on this journey thank you all of you!
    • Marked as answer by j-howard3 Monday, February 17, 2020 3:44 AM
    Monday, February 17, 2020 3:44 AM

All replies

  • For the github attempt I did remove the database files from .gitignore file I'm just not sure if .aspx files will work on githubpages but essentially all of this is based off of the original problem.
    Tuesday, February 11, 2020 7:32 AM
  • Hello j-howard3,

    Firstly, could you post the permission error massage? Then we can analysis the specified cause.

    If your error message as below: 

    System.Data.SqlClient.SqlError: The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DataLabTables.mdf'.

    You had to do was tick the box marked 'Relocate all files to folder' on the 'Files' section when you restore database:

    Hope it will help. And if it still not, please post the permission error massage.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, February 12, 2020 8:50 AM
  • UPDATE.... I am have built a website in Visual Studio 2019 to use as a portfolio demonstration of SQL and Reporting skills. I didn't know C# so I studied for a bit and got it built and up and running on my local machine. For the purpose of providing a link to recruiters on my resume, I want to publish the site on the internet. I tried a free hosting service and github pages to attempt this (didn't work my ignorance). I can move my database to the IP address and folder structure of the hosted site address. Once uploaded I changed the the Connection Strings of the Database within my asp.net files to the Connection String offered by my hosting. After some headaches I was able to do so. (MAYBE THE PATH OF MY CONNECTION STRING IS WRONG? i will post pics soon). Assuming my ConnectionString is right when I use the Login Page I created On the Site to query a table of users and Confirm Password I  get "Access Denied due to Permissions error". This is farthest I have gotten. I tried removing the Database I created on My Local Machine from Website. Then in SSMS Run the "RightClick on Database--Tasks--Generate Scripts" From my local machine. I checked the boxes for "Include Tables and Data and Include Logins". I saved this script and ran it on the hosted website online to recreate my Database hopefully to solve my permissions issue..... But It Didn't. Here is an error on my FREE hosting when trying to restore from a .bak file i created also same error with uploaded .mdf file and scripted out database file (which is why I believe it to be a permissions issue if the empty server I'm the admin of wont restore a .bak file or....my permissions on the hosted machine are limited???. I will pay for Hosting elsewhere to hopefully get more space for DB and HD space. Thanks for taking your time to look at this guys I appreciate it. Sorry about my ramble of a post I was very frustrated. NOT SURE OF PROBLEM IS DATABASE PROPERTIES(cant read/write) OR HOSTED SITE PERMISSIONS (I AM ADMIN OF SITE???), OR BAD SETTINGS WHEN SCRIPTING DATABASE 

    It wonlt let me post pics but here is what the hosted machine says for the error when trying to restore .bak, or move/use the scriptesd out DB, or upload Local DB and use that.....   "BlahBlah.mdf" Operating System ERROR Access Denied RESTORE FILELIST TERMINATIONG ABNORMALLY."

    Wednesday, February 12, 2020 7:26 PM
  • Hello,

    For :"BlahBlah.mdf" Operating System ERROR Access Denied RESTORE FILELIST TERMINATIONG ABNORMALLY."

    That Sounds like the service account that SQL Server runs under does not have permission to folder of your .mdf file. You need to give permission to that folder to the user account that SQL Server acts as. As follow picture: 

    Untick Read-only & grant premission to the service account that SQL Server runs

    Hope it will help.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, February 13, 2020 8:08 AM
  • Thank you for all of your super fast responses. I tried the FILE PROPERTIES--CHANGE from READ-ONLY option and file group options and a few others but no success. But its OK. I am truly impressed that I got 1 response let alone a few of them. So I am very grateful to you guys. I am going to contact the support team of my hosting company to see if I'm doing something wrong on their side of things. I know you are supposed to put a database in a "PROTECTED FOLDER" OF SORTS TO KEEP PEOPLE FROM JUST RIPPING IT FROM WEBSITE it could be a restriction programmed into system. Thanks again for your help. If the hosting company gives me any insight I will post what they said. Thanks again and I appreciate the community input. My teacher said this forum was very involved and I can see that. Thank you for your help and suggestions!
    Friday, February 14, 2020 12:26 PM
  • Hello,

    Thanks for your feedback.  And it's very kindful that you share the solution here if you solve the problem. Hope you can solve the problem within your hosting company assistance.

    Meanwhile, any other issue, you can tell us as well. Thanks.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 17, 2020 2:57 AM
  • Turns out it was hosting issues. They wouldn't give me admin permissions so.... They had to restore database then... They had to rename database so my stored procedures worked... They also had to change the login to said database to work for their systems. So I'm up and running. turns out I did nothing wrong but.... changing files from "read only" to "read/write" did help me on this journey thank you all of you!
    • Marked as answer by j-howard3 Monday, February 17, 2020 3:44 AM
    Monday, February 17, 2020 3:44 AM