CLR Stored Procedure connection exception


  • 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=, 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.

    connection strings:

    @"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;"

    @"Server=WIN7SERVER;Database=FMGAPP;Trusted_Connection=True;Integrated Security=True";

    @"Data Source=Win7Server;Initial Catalog=FMGAPP; User id=userid;Password=password";


    Thanks in advance.

    John McKelvey

    • Modifié J-Mac mardi 6 mars 2012 13:22
    mardi 6 mars 2012 13:21

Toutes les réponses