Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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=2.0.0.0, 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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.