none
"User does not have permission to perform this action."

    Question

  • Hi, im using visual studio 2010 to build a website with DB and i created .MDF DB using visual studio.

    As long as i am running the website with visual studio (Ctrl + F5) everything is going well, but when i upload my website to a host, i get this error:


    Exception Details: System.Data.SqlClient.SqlException: User does not have permission to perform this action.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Exception Details: System.Data.SqlClient.SqlException: User does not have permission to perform this action. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    it says i dont have a premission to the DB but it did work on VS,
    how do i get premission to the DB?

    sorry for the bad english

    Friday, June 29, 2012 2:13 PM

Answers

  • Hi iAmNewbSorry,

    Sorry for the impolite since I don’t know your name and I can only use the forum id as your name.

    For checking the iis account you are using, please see this website:

    How Do I Determine the Security Account that IIS Uses to Run My Web Site?

    After you checked that, open your SQL Server Management studio, check if this account is in “security”—“logins”. If it is, right click the account, select “properties”, you can see the “user mapping” tab, map the database you want to access, select the database roles you want.

    For more information, you can see:

    Database-Level Roles

    If the account is not listed in the “logins”, please add the account to SQL Server. Please refer to:

    How to: Create a SQL Server Login

    After you created it, please also grant permission to the account as I mentioned above.

     

    Best Regards,
    Iric
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 03, 2012 9:50 AM
    Moderator

All replies

  • it says i dont have a premission to the DB but it did work on VS,
    how do i get premission to the DB?

    sorry for the bad english

    No, not you.

    See, when you start the site from Visual Studio, then it's running under your Windows account and also the connection to SQL Server is opened with your Windows credential (in connection string there is a property like "Integrated Security=True" or =SSPI, I guess).

    When you deploy you site, then it runs under the account of IIS and connects with this account and this account don't have the permissions to access the database.

    Check which account is used by IIS (something like ASP_USER) and grant access & permissions for that account in SQL Server + for the database.

    P.S. my English is also not the best, so don't worry about it.


    Olaf Helper
    * cogito ergo sum * errare humanum est * quote erat demonstrandum *
    Wenn ich denke, ist das ein Fehler und das beweise ich täglich
    Blog Xing

    Friday, June 29, 2012 2:48 PM
  • it says i dont have a premission to the DB but it did work on VS,
    how do i get premission to the DB?

    sorry for the bad english

    No, not you.

    See, when you start the site from Visual Studio, then it's running under your Windows account and also the connection to SQL Server is opened with your Windows credential (in connection string there is a property like "Integrated Security=True" or =SSPI, I guess).

    When you deploy you site, then it runs under the account of IIS and connects with this account and this account don't have the permissions to access the database.

    Check which account is used by IIS (something like ASP_USER) and grant access & permissions for that account in SQL Server + for the database.

    P.S. my English is also not the best, so don't worry about it.


    Olaf Helper
    * cogito ergo sum * errare humanum est * quote erat demonstrandum *
    Wenn ich denke, ist das ein Fehler und das beweise ich täglich
    Blog Xing

    Thank you for the answer

    Im sorry for the newbie question but i have never worked with sql before,
    how do i check the ISS count and grant premission ? 
    (i have sql server managment studio 2008 express if it's needed)


    Friday, June 29, 2012 3:54 PM
  • Hi iAmNewbSorry,

    Sorry for the impolite since I don’t know your name and I can only use the forum id as your name.

    For checking the iis account you are using, please see this website:

    How Do I Determine the Security Account that IIS Uses to Run My Web Site?

    After you checked that, open your SQL Server Management studio, check if this account is in “security”—“logins”. If it is, right click the account, select “properties”, you can see the “user mapping” tab, map the database you want to access, select the database roles you want.

    For more information, you can see:

    Database-Level Roles

    If the account is not listed in the “logins”, please add the account to SQL Server. Please refer to:

    How to: Create a SQL Server Login

    After you created it, please also grant permission to the account as I mentioned above.

     

    Best Regards,
    Iric
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 03, 2012 9:50 AM
    Moderator