Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561

A Web part/InfoPath form with managed code causes the above error.

Cause: DLL's that access databases require at least the WSS_Medium security policy in the web.config file.
If you receive a security message from the web part, it's usually the trust element in the web.config file.

You could also have a dll outside the GAC that's trying to access some part of the SharePoint Object Model.

There's a couple of ways to resolve this issue.

  1. Put you dll in the GAC. I don't like putting limited use web parts in there and managed code for InfoPath doesn't like it.
  2. Open wss_mediumtrust.config & wss_minimaltrust.config usually (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\config\) look in your web.config file for the exact path.

    Find in wss_mediumtrust.config:

    <SecurityClass Name="SqlClientPermission" Description="System.Data.SqlClient.SqlClientPermission, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

    Copy and paste it in to the <SecurityClasses> node of wss_minimaltrust.config.

    In the PermissionSet section of this configuration file, add the following:
    Find in wss_mediumtrust.config: <IPermission class="SqlClientPermission" version="1" Unrestricted="true"/>

    Copy and paste it in to the a <PermissionSet> node of wss_minimaltrust.config. That about covers it.
  3. You could also set the trust level to "wss_mediumtrust" or create a custom trust level. Google it...


  1. Finally a solution to this! Ever since sharepoint was installed on our development server we had several permissions issues that we just could not figure out how to resolve. This did the trick! Thanks a bunch for posting this!

    Randy Jean

  2. Thanx master...
    Greate post!!!!

    Was helpful for me.

    Eric Ramírez

  3. thanks a lot that did the trick