[Solved] Microsoft.Data.SqlClient.SqlException (0x80131904): The INSERT permission was denied on the object, database, schema 'dbo'

The Microsoft SQL Server exception Microsoft.Data.SqlClient.SqlException (0x80131904): The INSERT permission was denied on the object, database, schema ‘dbo’ is the permission-related issue we can able to predict based on the exception details. There are similar issues like this because this particular issue is related to INSERT permission, similarly, there can be issues related to SELECT permission, DELETE permission, UPDATE permission, EXECUTE permission, and Create Table permission.

Problem

When I try to host the application for the first time on the IIS server, I faced several problems running the application. One of the issues is Microsoft.Data.SqlClient.SqlException (0x80131904): The INSERT permission was denied on the object, database, schema ‘dbo’. My application had code to Insert and select data from the database. The application was failing and it was throwing the above exception.

Solution

If we analyze the issue, we can clearly understand that issue is related to permission. Right-click on your database to get the Database Properties window then navigate to the permission option, The user I am using is NT/AUTHORITY\LOCAL Service. So have to select the appropriate user and in the table, we can able to see a list of actions with a checkbox to select Grant for each action as shown image below.

I supposed to check the Select action and Insert action to solve my present issue, but I may use other actions also for database transactions. So I could give all-important permissions and solved the permission issue. Just need to check the required action type and hit ok as shown below image.

Conclusion

I got this error along with series of errors while hosting my ASP.NET Core web application on IIS hosting platform for the first time. I have shared other errors also with solution below.

  1. Cannot open database requested by the login. The login failed. Login failed for user IIS APPPOOL
  2. Cannot open database requested by the login. The login failed. Login failed for user ‘NT AUTHORITY\LOCAL SERVICE’
  3. This issue which discussed in this article.

Sreenivasa Rangan

Software professional with 9+ years of experience in all phases of software development with robust problem-solving skills and proven experience in creating and designing software in a test-driven environment.

Post a Comment

Previous Post Next Post