Took a few searches to find this one, but, while converting my database from the build in VS server to using IIS my connection string was failing on attempting to connect to the database, with an error message of:
Cannot open database "[databasename]" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\[the site's apppool name]'.
Long story short, in IIS 7.5 the AppPool is given serveral different identities: Local Service, Local System, Network Service and ApplicationPoolIdentity (the default). You can find this in
IIS Manager : Application Pools : Right click on the app pool for your site : Advanced Settings : Process Model : Identity : Select from the ... button
In my case, network service has permissions to hit the database but the new ApplicationPoolIdentity did not. Either change the App pool identity or give ApplicationPoolIdentity permissions.