473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can't connect to SQL Server

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.


--
RW
Jul 18 '07 #1
3 2083
On Wed, 18 Jul 2007 10:10:01 +0200, RW <RW@discussions.microsoft.comwrote:
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.

....

--
Happy coding!
Morten Wennevik [C# MVP]
Jul 18 '07 #2
Thanks Morton

In the meantime I found the solution for my problem.
It was a security problem. My application was located on a shared server.
I just needed to add that server to the trusted list with mscorcfg.msc.

see atrticle: http://msdn2.microsoft.com/en-us/lib...xc(vs.71).aspx
--
RW
"Morten Wennevik [C# MVP]" wrote:
On Wed, 18 Jul 2007 10:10:01 +0200, RW <RW@discussions.microsoft.comwrote:
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.



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 server and 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.

....

--
Happy coding!
Morten Wennevik [C# MVP]
Jul 18 '07 #3
I found the solution for my problem.
It was a security problem. My application was located on a shared server.
I just needed to add that server to the trusted list with mscorcfg.msc.

see atrticle: http://msdn2.microsoft.com/en-us/lib...xc(vs.71).aspx
--
RW
"RW" wrote:
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.


--
RW
Jul 18 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: webhead74 | last post by:
Hi, I've worked on this for a couple of days & can't figure out what I'm doing wrong. I'm trying to connect to a remote AS400 database using odbc & php. Here's my environment: Server: RedHat...
0
by: Ryan Stewart | last post by:
I'm running MySQL server on a WinXP box at home. I have a cable modem/router. I've set up port forwarding on port 3306 to the machine running MySQL. I can connect locally just fine, but when I try...
0
by: Zorba.GR | last post by:
IBM DB2 Connect Enterprise Edition v8.2, other IBM DB2 (32 bit, 64 bit) (MULTiOS, Windows, Linux, Solaris), IBM iSoft Commerce Suite Server Enterprise v3.2.01, IBM Tivoli Storage Resource Manager...
18
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
0
by: Clodoaldo Pinto | last post by:
Can't connect to postgresql server php error log message: PHP Warning: pg_connect() : Unable to connect to PostgreSQL server: could not connect to server: Permission denied\n\tIs the server...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
5
by: Jack | last post by:
Hello, I had SQL2000 server running fine on the windows 2003 box. I then installed SQL 2005 Express. They both worked together fine. I then uninstalled SQL 2005 Express and installed SQL 2005...
12
by: smerf | last post by:
I have searched high and low (and even in some places I'd like to forget I ever saw) for the information that will tell me exactly how the Nat2Nat server for UltraVNC works (not just a vague...
2
by: jeffhan | last post by:
we have os/400 db2 database at the backend. i installed db2 v9 connect server on one windows server which is locating the same network with database server. now how to i configure the connect...
0
by: Hugo Kornelis | last post by:
On Wed, 3 Sep 2008 00:52:26 -0700 (PDT), Ascerbus wrote: Hi Ascerbus, What makes you think that it's trying to connect. Do you get any error messages? Is the connect dialog box still...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.