Domanda

I'm trying to connect to my db on my local machine with the following connection string and it fails for the following connection string

conn = new SqlConnection("Server=(local);DataBase=dnn6;Integrated Security=SSPI");

I'm using IIS 6 as my web server and when I open that page I get the following error.

Cannot open database "dnn6" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\demo'.

I'm using SQL Server 2012

È stato utile?

Soluzione

The problem is that the IIS account being used to access SQL Server (IIS APPPOOL\demo) does not have access to it.

You need to either:

  • grant permission for the user IIS APPPOOL\demo to your SQL Server
  • use impersonation to connect to SQL Server with a user account that has access
  • use SQL Server Logins to access SQL Server using a named user (not recommended these days)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top