0

I try to connect from webpart to database server. Error happen in the line:

conn.Open()

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

I'm using Sharepoint 2013 version.

1 Answer 1

1

You should deploy the assembly of the web part to the Global Assembly Cache (GAC), configure full trust for the application in the web config, or create a custom trust, that allows this kind of database interaction.

I suggest you to read the following articles to get a deeper insight into the Codes Access Security:

Microsoft Windows SharePoint Services and Code Access Security

Code Access Security and SharePoint 2007 Web Parts

3
  • I'm using Visual Webpart so there is no web config. What is the instead solution to trust for app. Commented Mar 19, 2015 at 8:10
  • Web.config is always there in the root of the SharePoint web application in IIS. Commented Mar 19, 2015 at 8:31
  • The typical path where you should find the web.config file is C:\inetpub\wwwroot\wss\VirtualDirectories[your web app name] Commented Mar 19, 2015 at 8:41

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.