0

I am trying to connect to a database from an ASP.NET web application. However, I am getting the following exception:

Cannot open database "Books" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\ASP.NET v4.0'.

This is the connection string that I am using:

<add name="DB_Connection" connectionString="data Source=.\ANTONIO;Initial Catalog=Books;Integrated Security=true" providerName="System.Data.SqlClient"/>

This is a screenshot of the server that I am trying to connect to:

enter image description here

What am I doing wrong? Is the connection string wrong? Or is it something else?

Update

This project was deployed on IIS server. I removed it from IIS server and started it as a normal project. It works so the problem is not the connection string.

It seems that the IIS server account is not able to access my database. How can I solve this please?

Matthew
  • 4,477
  • 21
  • 70
  • 93

2 Answers2

1

It doesn't appear that your connection string is coming through in your post.

The first thing I would test is to ensure that you can connect to the SQL database with the user account directly.

The second thing I would check is to ensure your APPPOOL has the correct permission on the site folder. Typically a site will have an APPPOOL based on the site name rather than the .Net version...

If you can get your connection strings to display, I could better troubleshoot.

Also... you may want to check http://www.connectionstrings.com/sqlconnection/

YOOOEE
  • 151
  • 10
1

In SQL Server Management Studio you need to go to Security -> Logins -> Create New then create a new Windows login for your IIS APPPOOL\ASP.NET v4.0 user. Then in User Mappings give the new login the needed access to Books. You can give it read/write/alter privileges as needed.

Vulcronos
  • 3,428
  • 3
  • 16
  • 24