This is a common error shown when SQL server is not mapped with the database you need to access. Follow the steps below for a resolution
- Go to Security folder in the server.
- Double click it and go to Logins folder.
- Find your user id and double-click it.
- Login Properties window will open up.
- In that go to User Mapping.
- Tick all the Databases that you want to map with that Login.
This can also be achieved using a SQL (specially if you are restoring a db)
USE dbNamw;
ALTER USER {userName} WITH login = {loginName}
Cheers
Samitha