1
votes

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, Func
1 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.

2

2 Answers

3
votes

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
0
votes

I had a different issue. I already had done changing permissions to 'db_owner', but it still didn't fix my problem. Then I changed DefaultAppPool to 'NetworkService' in IIS Manager. It fixed my issue.