System.Data.SqlClient.SqlException: The SELECT permission was denied on object 'tableName', database 'dbName', schema 'dbo'

I try to SELECT some data from SQL Server via my ASP.NET MVC web-app which is hosted in a Local IIS 7 and I'm getting this error:

System.Data.SqlClient.SqlException: The SELECT permission was denied on object 'tableName', database 'dbName', schema 'dbo'.

Knowing that all the IIS APPPOOL\ASP.NET V4.0 Integrated's privileges are checked, how do I to fix this, please?

Stack trace:

[RuntimeBinderException: Cannot perform runtime binding on a null reference] CallSite.Target(Closure , CallSite , Object ) +200 System.Dynamic.UpdateDelegates.UpdateAndExecute1(CallSite site, T0 arg0) +924 ASP._Page_Views_Shared__Header_cshtml.Execute() in c:\Users\Nectarys\desktop\monitoringn_web\monitoring2 - copy\monitoringn\Views\Shared_Header.cshtml:11 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +126 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +196 System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +158 ASP._Page_Views_Shared__Layout_cshtml.Execute() in c:\Users\Nectarys\desktop\monitoringn_web\monitoring2 - copy\monitoringn\Views\Shared_Layout.cshtml:13 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +126 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +196 System.Web.WebPages.WebPageBase.Write(HelperResult result) +89 System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action1 body) +233 System.Web.WebPages.WebPageBase.PopContext() +291 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +378 System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +33 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 continuation) +855148 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265 System.Web.Mvc.Async.<>c_DisplayClass25.b_22(IAsyncResult asyncResult) +839620 System.Web.Mvc.<>c_DisplayClass1d.b_18(IAsyncResult asyncResult) +28 System.Web.Mvc.Async.<>c_DisplayClass4.b_3(IAsyncResult ar) +15 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +65 System.Web.Mvc.Async.<>c_DisplayClass4.b_3(IAsyncResult ar) +15 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +51 System.Web.Mvc.<>c_DisplayClass8.b_3(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.<>c_DisplayClass4.b_3(IAsyncResult ar) +15 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +51 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

Also, I've grant SELECT,INSERT,UPDATE,DELETE on dbo.tableName to "IIS APPPOOL\ASP.NET V4.0 Integrated";. I've did this by selecting the dbName and making in new script in which I've written that line.

Answers


Hmmm... It is not because IIS APPPOOL\ASP.NET V4.0 Integrated, but it is from your database.

  1. Please kindly login to SQL server
  2. Go to your database --> expand it
  3. Security--> your db user
  4. Right Click--> properties
  5. Please make sure whether db_denydatareader and db_denydatawriter untick

Hope this help


Your db user do not have rights to read from table's in db. You can give it db_owner rights and it should work.

  1. Login to SQL server
  2. Go to your database --> expand it
  3. Security--> your db user
  4. Right Click--> properties
  5. Make sure that db_owner is selected

Need Your Help

Check if a specific Linux Terminal is already open

linux terminal centos7 tail mate-desktop

We have a Server Startup Script that is calling a Mate Terminal (or GNOME Terminal - should not make a difference) as Part of the Server Startup process which is, in essence, tailing the Servers in...

Adding TypeKit code (or any code) into the Head of a Magento 2 site

magento head magento2

All I want to do is to add a custom font from TypeKit into my Magento 2 website.