If I've understand everything you put on this thread, you problem is security related.
In your
web.config
, you probably have connection string like this:
<connectionStrings>
<add name="MyDb" connectionString="data source=MyServer;initial catalog=MyDb;integrated security=True;" />
</connectionStrings>
Where
integrated security
could be replaced with
Trusted_Connection
. This is telling ADO.NET that you want to the account the web application is running under to connect to the database. When you create a new application pool in IIS, it uses a default account to run your web application. This account does not have permissions to access your database and which is why the connection is failing.
To fix this, you have two options. The first is setup a service account that can access the database in question. Below are a few links to help you out with that.
Accessing Database in IIS Applications[
^]
Specify an Identity for an Application Pool (IIS 7)[
^]
Create Database User[
^]
Your next option would be to create a SQL Server account, not a network account like in the examples above. If you accepted all of the defaults during the installation of SQL Server, then it setup for Windows Authentication and would need to be changed to Mixed Authentication. This will allow for both Windows accounts and SQL Server accounts. Take a look at
Creat a Login[
^] on the MSDN site, specifically step 5. If you go this route, you would end up with a connection like this:
<connectionStrings>
<add name="MyDb" connectionString="data source=MyServer; initial catalog=MyDb; User Id=myUsername; Password=myPassword;" />
</connectionStrings>
The preferred method tends to be the first option I gave. This leaves the password out of the hands of the developers and helps to keep the application secure. If you go with the second option, you really should look into encrypting your configuration files to keep the password safe.
I hope this helps you out.