The error message is:
Cannot open database "POS" requested by the login. The login failed.
Login failed for user 'HSSS'.
There are two possible causes for this error:
- The database POS does not exist in this instance
- POS exists, but the login HSSS does not map to a user in this database.
I note that your connection string says Data Source =.
. That is, you are logging on to the local instance. Obviously, just because a database exists on one machine, it does not mean that it exists on the other. So that is the first thing to check.
But I also note that you say when I move my database from one PC to another. And if that is what you have done, this can explain the problem. The mapping between login on server level and user on database level is not by name, but by SID. When you create an SQL Login on two different servers will typically have different SID - unless you take precautions.
That is, let's say you have created a login HSSS on server A, and now you want to move your database to server B. On server A, you run
SELECT suser_sid('HSSS')
When you create the login on server B, you say:
CREATE LOGIN HSSS WITH PASSWORD = '123456', SID = 0x...
where 0x... is the value you got in the first query.
In this case you have already created the login, so you need to drop it first.