That is odd. Maybe you could special case your web part to not do the database call when the page is in edit/design mode. Wouldn't that fix your problem?
views:
650answers:
3Try setting up a solution package to deploy code access security settings. You definitely need SqlClientPermission. Check out my post on Code Access Security for web parts for more information.
As a simple test, you could deploy the assemby containing the web part into the GAL. There it will run with Full Trust.
Personally, I would not recommend establishing a database connection in the constructor of a web part unless you had a compelling reason to do so.
[updated 3009-03-27]
Debugging is often about ruling out causes. Even though you believe the web part is running in Full Trust, I recommend testing the GAC'ed case. Remember to remove the .dll from the Bin directory for the test. This will only take 5-10 minutes and you'll know where you stand.