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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems connecting to remote SQL 2005 Express from VB .Net 2008 Xprs

Status
Not open for further replies.

ALWilliams

Programmer
Jun 29, 2007
21
GB
I'm trying to code a small app where it connects to a remote SQL server 2005 Express database and return some values and display that onto the form.

I have managed to get the code to connect to the database (well it never raised any errors) - but when I actually try to do anything I get a security error.

The code in question is:

Dim accountsQuery As String = "Select * From Alpha" Dim cnn1 As New SqlConnection("Data Source=<SERVERNAME>\SQLEXPRESS; ;User ID=<USERNAME>;password=<PASSWORD>;DATABASE=<MYDBNAME>;Integrated Security=False;User Instance=True")

NewAccountDataset = New DataSet
newAccountTableAdapter = New SqlDataAdapter(accountsQuery, cnn1)

newAccountTableAdapter.Fill(NewAccountDataset, "accounts")

upon it getting to the last line it errors with the following reply:

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

Any ideas much appreciated.
 
When I've tried to use the express sql server in the past I've had to set some properties up.

Open the SQL Server Surface Area Configuration tool found in Microsoft SQL Server 2005/Configuration Tools from the Start menu in windows.

Select the Surface Area Configuartion For Features link at the bottom.

Select CLR Integration and then enable CLR Integration

That has worked for me in the past.
 
It ended up being that the application needed to be trusted so added this option and it started to work fine.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top