Having answered this question I know about 100 times (at least
it's good that there now is a Microsoft Knowledge Base article that explains the process!
Enjoy!
If you are developing custom web parts that need to connect to a SQL Server database to retrieve data, you may be confronted with the following error:
{"Request for the permission of type System.Data.SqlClient.SqlClientPermission, System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed." }
This is due to SharePoint Portal Server and Windows SharePoint Services implementation of .NET Code Access Security (CAS). A solution that addresses the aforementioned error is cited below:
<SecurityClass Name="SqlClientPermission"
Description="System.Data.SqlClient.SqlClientPermission, System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<IPermission class="SqlClientPermission" version="1" Unrestricted="true" />
If you still run into the error, try adding these settings to the wss_mediumtrust.config file.
Hopefully, this will save someone hours of web part debugging time. ![]()