I am using Quartz.NET to do some background processing where ultimately I make a connection to my SQL Server. This all works locally on my development machine against IIS Express, but when I deploy it to my staging server running IIS I run into problems.
The code to connect to the database could not be simpler:
myConnection = new SqlConnection("Data Source=127.0.0.1;Initial Catalog=MyDB;User ID=sa;Password=myPass");
however this throws an exception of:
System.Data.SqlClient.SqlException: Login failed for user 'IIS APPPOOL\somehost.somedomain.com'.
I am 100% confident the connection string is correct as when used in a normal page it works just fine. So what is throwing me is the reference to IIS APPPOOL.
Is the SqlConnection somehow not using the connection string it was passed? Doing some form of weird user impersonation when the connection is being made?
Put another way. How do I make the SqlConnection() work from within the thread when I know the connection string is correct?