SqlClient.SqlClientPermission ???

Posted on 2006-05-08
Last Modified: 2010-05-18
I have this little piece of code that works find on my computer. Then when I upload it to my work computer, on a network it fails. Both have SQL 2000 server.

This is the code:

        Dim c As String = Me.TextBox1.Text.ToString

        Dim conn As New SqlConnection(c)
        Dim cmd As SqlCommand = New SqlCommand("select * from " & Me.TextBox2.Text.ToString, conn)
        cmd.CommandType = CommandType.Text
        Dim reader As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)

the connection string is this -
"Data Source=(local);Initial Catalog=AhavaOrder;Integrated Security=True"

The error is very long, but this seems to be the main part

System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=, Culture=neutral,

The type of the first permission that failed was:

Can anyone explain to me what is going on here? I must have overlooked something big.

Question by:rrr333222
    LVL 96

    Expert Comment

    by:Bob Learned
    1) The security model for .NET is a tricky thing.  

    2) If you copy the .exe file down to a local drive, does it work?


    Author Comment

    The network has citrix. So I ran it both from a computer that is connected to the SQL Server as wel as from the Server itself. Same result!. And strangely I have no trouble accessing the database from Query Analizer or from an Access Database using OleDBODBC.
    LVL 6

    Accepted Solution

    I think your assembly has using the Framework Configuration Wizard. If this is a web app, then possibly the minimum security trust level has been configured? The solution would be to temporarily set the trust level (within web.config) to 'Full', see if it works.

    If this is the case, then you need to create a new configuration file.

    Details for this are found at:

    in a white paper called:

    Security Solutions Offered by Visual Studio .Net 2005 (Whidbey)

    If it's a Windows app, then check the permissions your app has through the Framework Configuration Wizard. My guess is that the defaults have been changed. The easiest way to restore this (only do this on a development machine, not production!) would be to right click on each security level (under Runtime Security Policy) and select 'Reset...'

    Hope this is useful


    Author Comment

    I have a new clue, but no solution.

    I seems that this program will run from any of the local drives of either the Citrix server or SQL Server. The other drives from where it won't run are all Novell network drives. So while I am allways attempting to run this program from either the Citrix or SQL PCs - if the program is physically located on the Novell server then it won't work!

    Where do I go from here?
    LVL 96

    Expert Comment

    by:Bob Learned
    I don't have much experience with Novell these days, enough to answer that tricky question.


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    26 Experts available now in Live!

    Get 1:1 Help Now