Posted in: Programming by Steve on August 22, 2012
I run into this a lot while deploying new fixes. If you have a production and a stage environment, before deploying to production, you should backup and restore your database to the staging database to do all your UAT. However, if your usernames are the same, then you may run into an issue where SQL has an "orphaned" user that cannot be associated to the database (http://msdn.microsoft.com/en-us/library/ms175475.aspx).
USE [database_name] GO exec sp_change_users_login "auto_fix", "username";
That should get you back up and running.