locked
Windows based VB.Net application fails with "Request for the permission of type 'System.Data.SqlClient.SqlClientPermission..." error when the trust level is lowered one step down in MyComputerZone. RRS feed

  • Question

  • Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture = neutral, Public Token=b77.... failed. error occurred from the code snippet given below when the trust level is lowered one down from "Full Trust" in "MyComputer" zone.

    Exception is thrown from the line SqlConnection1.Open().

    When set back to default trust level (Full trust), code works fine.

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

            Try


                SqlDataAdapter1.SelectCommand.Connection.ConnectionString = TextBox1.Text

                SqlConnection1.Open()

                SqlDataAdapter1.Fill(DataSet11)

                SqlConnection1.Close()

            Catch ex As Exception

                MessageBox.Show(ex.ToString)

            End Try



        End Sub

    Tuesday, June 26, 2012 11:09 AM