Tuesday, March 06, 2012 1:21 PM
CLR Stored Procedure connection exception
I have a CLR stored procedure in one database which tries to make a connection to another database on another server. It fails on connection.Open() with the exception: "Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
var sameDocTypeCount = 0;
using (var connection = new SqlConnection(solomon))
string sqlStmt = @"SELECT count(*) FROM xfmAttach (nolock) WHERE KeyValue='" + workOrderId +"'";
var command = new SqlCommand(sqlStmt, connection);
sameDocTypeCount = Convert.ToInt16(command.ExecuteScalar());
I've tried setting up SQL Server for remote connections 1433 / TCP enabled, using a variety of connection strings but nothing works.
@"Server=WIN7SERVER;Initial Catalog=FMGAPP;Integrated Security=True";
@"Persist Security Info=False;Integrated Security=False;Server=server;initial catalog=FMGAPP;user id=server\user;password=password;"
@"Data Source=Win7Server;Initial Catalog=FMGAPP; User id=userid;Password=password";
Thanks in advance.
- Edited by J-Mac Tuesday, March 06, 2012 1:22 PM
Tuesday, March 06, 2012 3:00 PM
Did you try setting the permission level?
Set permissions to EXTERNAL_ACCESS. Go to the properties of the project (right-click on the project node, choose Properties), choose the Database tab, and then from the Permission Level combo-box, choose External.
Also, please check out the restrictions on the EXTERNAL_ACCESS security level:
Friday, March 16, 2012 2:05 PM
Follow the thread below. It may help you
Monday, March 19, 2012 11:29 AM
Below threads might help you.