'System.Security.SecurityException'

tresa123

New member
Joined
May 18, 2009
Messages
1
Programming Experience
1-3
Hi all,

I am getting this error for a long time and when googled it turned out that the error can be fixed using the medium trust level and teh minimal trust config files. even after changing teh SqL client permissions web_mediumtrust.config and web_miminaltrust.config files, I am stuck with the same problem.

ERROR MESSAGE:An unhandled exception of type 'System.Security.SecurityException' occurred in System.Data.dll

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

CODE USED:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
pubsubConnectToDatabase()
End Sub
Public Function pubsubConnectToDatabase()
Dim connString As String = "Data Source=" - ";Initial Catalog=" - ";Persist Security Info=True;User ID=" - ";Password=" - ""
Dim conn As New SqlConnection(connString)
Try
conn.Open()
MsgBox("connection")
Catch ex As SqlException
MsgBox("Error: " & ex.Message())
Finally
conn.Close()
End Try
Return conn
End Function

Thanks,
tresa
 
Back
Top