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
        cmd.Connection.Open()
        Dim reader As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
        reader.Read()
        MsgBox(reader.Item(0))

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=2.0.0.0, Culture=neutral,


The type of the first permission that failed was:
System.Data.SqlClient.SqlClientPermission


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


rrr333222Asked:
Who is Participating?
 
SandeepRRCommented:
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:

http://www.charteris.com/publications/whitepapers/default.asp 

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

Regrards
SandeepRR
0
 
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?

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

Bob
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.