1
votes

I'm using SQL Server 2014 in my local system. There is an MVC application with .NET Framework 4.6.1 and it worked fine.

Now, I've created a new MVC application with .NET Framework 4.7.2 and see this issue. The local website is unable to connect to the Database.

System.Data.SqlClient.SqlException Cannot open database "NewApp" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\dev.newapp.com'.

I have checked the User Mapping properties and both applications are listed. I did not make any changes in IIS or the SQL Server.

Also, I tried changing the Identity in IIS for DefaultAppPool to LocalSystem with no luck.

The IIS, SQL server & the website - all are in the same machine.
enter image description here

enter image description here

1
could you add a bit more details about your infrastructure please? is the SQL server and IIS running on the same machine, different machines, different domains...? - user7415753
@user7415753 all are on the same machine - Qwerty

1 Answers

1
votes

There a difference between Windows and SQL Server Authentication.

Per your images you have configured sa user which is SQL Server Authentication and you cannot use Windows Authentication in your application and web.config.

So, if you want to use sa login then update your web.config file and database connection string to be like:

Server=yourServer;Database=yourDatabaseName;User=sa;Password=saPassword;

or different syntax:

Data Source=yourServer;Initial Catalog=yourDatabaseName;User=sa;Password=saPassword;

Your application is trying to use local user as Windows authentication.