Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Client Permission problem.

Status
Not open for further replies.

opkpapp11

Programmer
Jan 31, 2008
9
0
0
US
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
 
Try this for your connection string

"server=opkpapp11;Trusted_Connection=yes;Initial Catalog=AIT;"


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top