locked
Unable to Connect to Local Database RRS feed

  • Question

  • User709251606 posted

    My website is hosted, so I had been using the hosts connection string and database for a few months.

    I am developing some new features now, and since the website is live I need to test these inserts before running through all of the records.

    The remote database was setup using SQL Server Management Studio 2014 with a connection to the remote database.

    I tried stepping through these in Visual Studio 2015 Pro, but the host does not allow remote connections like that.

    So, I backed up the remote database and restored it to my local machine.

    I went into the Database Connection's Properties > Settings to make sure both SQL Server and Windows Authentication mode were allowed.

    I also added my database user and set him as the 'db_owner' for that database.

    When I try to open the database in the VS2015 debugger, I get "Login failed for user".

    What did I forget to do?

    Tuesday, April 5, 2016 2:36 PM

Answers

  • User709251606 posted

    Reboot fixed whatever the issue was.

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 7, 2016 5:57 PM

All replies

  • User-821857111 posted

    You probably need to synchronise the user account your are trying to use with an existing SQL Server login on your server/machine. You can do this by running the following command against your database

    sp_change_users_login 'update_one', 'user', 'user'

    where 'user' is the name of the account you are trying to connect with.

    Tuesday, April 5, 2016 3:37 PM
  • User709251606 posted

    Maybe I did something wrong.

    Do I need to restart the server after doing that?

    In the pic below, you can see I ran the command, but then I still got the same error when I tried to open the connection.

    Tuesday, April 5, 2016 5:22 PM
  • User709251606 posted

    I also tried logging into the local connection using that same account, but it failed too.

    That user is only in that one database (mcl959), so I don't know if it even should be able to log into the SQL Server instance.

    I ran this command to change the password, and it completed with no errors.

    > ALTER LOGIN [mcl959_admin] WITH PASSWORD=N'NewPassword', DEFAULT_DATABASE=[mcl959], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF

    Instead of N'NewPassword", I pasted in the actual password from my Web.config file.

    I went back and re-ran my website, but it still will not let that account log in.

    I'm going to try a reboot....

    Tuesday, April 5, 2016 5:50 PM
  • User709251606 posted

    Reboot fixed whatever the issue was.

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 7, 2016 5:57 PM