Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Cause:
Anything that access database from SP requires 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.
Fix:
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=2.0.0.0, 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.
OR
The application pool aslo has db owner permision to pubs.