1

I'm trying to connect to a database running on my local machine from my web application. I can connect to other databases that I created but not this one that I restored from another server. I can connect to the database using the MS SQL Server Management Console and see the database contents, tables etc. but when I try to open an SQL connection I get the error:

"Cannot open database "[Database Name]" requested by the login. The login failed. Login failed for user '[DOMAIN\USERNAME]'"

I have tried setting the login properties User Mapping to dbo and set database role membership to db_owner. I also tried switching to mixed mode where I created a SQL account which also works in management studio but not in my application. My application code works with other databases so it's not the connection string, must be a permissions problem but I'm not seeing it. Any ideas?

1 Answer 1

5

When bringing over a backup from another server, the login names that exist under Security\Users is no longer valid because those logins (even though they are mapped to Windows accounts) are valid only for the server the database was on.

In effect, you will have to remove and then re-add the logins.

Sign up to request clarification or add additional context in comments.

1 Comment

While that may be true with the existing logins, I created new logins. And in any case, SQL Management Studio doesn't let you delete the dbo login.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.