• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

SqlClient.SqlClientPermission ???

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.

  • 2
  • 2
1 Solution
Bob LearnedCommented:
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?

rrr333222Author Commented:
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.
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

rrr333222Author Commented:
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?
Bob LearnedCommented:
I don't have much experience with Novell these days, enough to answer that tricky question.


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now