Can't connect to SQL Server

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Using this code:

Dim oConn As SqlClient.SqlConnection
oConn = New SqlClient.SqlConnection()
oConn.ConnectionString = "..." 'Connection string I got via an .udl file
oConn.Open()

I get an error here:

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

I tried to connect to an other database I normaly can connect to in an other
application: same error
I copied the connection string from an application that can connect to the
database and tried to connect: same error
I moved my database local and tried to connect: same error.
 
Using this code:

Dim oConn As SqlClient.SqlConnection
oConn = New SqlClient.SqlConnection()
oConn.ConnectionString = "..." 'Connection string I got via an .udl file
oConn.Open()

I get an error here:

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

I tried to connect to an other database I normaly can connect to in another
application: same error
I copied the connection string from an application that can connect tothe
database and tried to connect: same error
I moved my database local and tried to connect: same error.

It would really help if you provide as much information as you can in these cases. From what you have written, it would appear that the database (or at least the server) is healthy, yet your application is denied access to this specific database, or to all databases?

If you are using a login, verify that the login exists on the sql serverand has proper access. Verify that the server allows logins and not windows authentication only.

If you are accessing using a web application, verify the proper, you need to take the user account the web application is running under into account when using windows authentication.

If you are developing a webpart in sharepoint or similar, you may have trust considerations as well.

....
 
Back
Top