SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have developed a web part and trying to access the SQL Server 2008 from the button click Event in the web part and I get the following error.

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

I have tried this post but not helped me. I want to find out what is cause for this error.

This Post

share|improve this question

If you are using Windows authentication on SQL server most likely you have double-hop issue:

Sharepoint Single Sign-On, Impersonation and the Double-Hop Problem

Simplified: user credentials are 'lost' when you reach SQL server and SQL denies your request.

Simplest solution for this is to put your SQL server in mixed mode and use SQL Server Authentication to allow access from your webpart.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.