Request for the permission of type 'System.Data.SqlClient.SqlClientPermission

  • I have a custom assembly with the below code. When I try to call the function from BIDS, I receive the message: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    All my online search has shown the solution once deployed, but I am receiving this message from within the BIDS.

    I have other functions within the assembly that are called fine, this is the only function that is creating a connection to retrieve data.

    I am not sure how to address this error message from within the BIDS. I am hoping someone may be able to assist me. Thank you all in advance for any help you can offer.

    public static string sprocUnivCodeToIdDispName(string vCode2Id, string vCode2IdType)

    {

    SqlClientPermission permission = new SqlClientPermission(PermissionState.Unrestricted);

    permission.Assert();

    SqlConnection conn = new SqlConnection("Data Source=xxxx;Initial Catalog=xxxx;Integrated Security=SSPI;user id=xxxx;password=xxxx");

    SqlCommand cmd = new SqlCommand("Rpts.spOpsFloUnivCode2IdDispName", conn);

    cmd.CommandType = CommandType.StoredProcedure;

    cmd.Parameters.Add("@vCode2Id",SqlDbType.NVarChar,-1);

    cmd.Parameters.Add("@vCode2IdType", SqlDbType.NVarChar, -1);

    cmd.Parameters["@vCode2Id"].Value = vCode2Id;

    cmd.Parameters["@vCode2IdType"].Value = vCode2IdType;

    string vRtnVal = "";

    try

    {

    conn.Open();

    SqlDataReader reader = cmd.ExecuteReader();

    while (reader.Read())

    {

    vRtnVal = reader["ReturnValue"].ToString();

    }

    conn.Close();

    }

    catch (SqlException ex)

    {

    Console.WriteLine(ex.Message, ex.Number.ToString());

    }

    return vRtnVal;

    }

Viewing post 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply