I am trying to connect to a Sql Server 2005 and am having a very hard time doing it. I found lots of other people with this problem on google but all of their solutions did not work for me. I am using VS 2005.
I have this error:
Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Here is my code
Dim sqlconn As New SqlConnection
'This is the building of the connectionstring.
sqlconn.ConnectionString = "server = opkpapp11; Database=AIT;integrated security=true"
'Here we are using a Try Catch block to trap any errors.
Try
sqlconn.Open()
Catch ex As Exception
MessageBox.Show(ex.Message, "Connection to Sql Server Failed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
'Now after the Try Catch here ,we are checking connection state using the State property
' which means that State 1 is connected and 0 is not connected.
If sqlconn.State = 1 Then
Me.Text = "You are successfully connected to Sql Server!"
Me.BackColor = Color.CadetBlue()
End If
Thanks
I have this error:
Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Here is my code
Dim sqlconn As New SqlConnection
'This is the building of the connectionstring.
sqlconn.ConnectionString = "server = opkpapp11; Database=AIT;integrated security=true"
'Here we are using a Try Catch block to trap any errors.
Try
sqlconn.Open()
Catch ex As Exception
MessageBox.Show(ex.Message, "Connection to Sql Server Failed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
'Now after the Try Catch here ,we are checking connection state using the State property
' which means that State 1 is connected and 0 is not connected.
If sqlconn.State = 1 Then
Me.Text = "You are successfully connected to Sql Server!"
Me.BackColor = Color.CadetBlue()
End If
Thanks