MSSQL error permission error

Posted on 2012-08-20
Last Modified: 2012-08-28
The SELECT permission was denied on the object '....', database '.....', schema 'dbo'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: The SELECT permission was denied on the object '.....', database '.......', schema 'dbo'.
Question by:shpresa
    LVL 75

    Expert Comment

    by:Anthony Perkins
    That means that the ASP user does not have GRANT SELECT permissions on the table.
    LVL 75

    Accepted Solution

    Word of caution and although this may sound counter intuitive, but doing a GRANT SELECT ON TableName TO ASPUser, may actually not be the best solution.  You are better off including it in a Stored Procedure and doing a GRANT EXECUTE ON StoredProcedureName TO ASPUser.  That is of course if the SELECT is not already in a Stored Procedure and not using Dynamic SQL.
    LVL 26

    Assisted Solution

    by:Alan Warren
    Hi shpresa,

    Can you log into your the SQL server using SQL Server Management Studio, providing the same credentials as defined in in your web.config connectionstrings?

    If so, can you then execute your 'Select' script from within SQl Server Management Studio?

    If not, you need to grant some permissions to the user account. To do so, you may need to logout of SQL Server Management Studio and login again using an Admin account, usually named sa, grant the necessary permissions, then logout as 'sa' and log in again using the account credentials defined in your web.config and test that you can now execute your SQL script. After which it should work from your asp .net application too.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video discusses moving either the default database or any database to a new volume.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now