.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SQL Connection problem

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
377 Views, 6 Replies

SQL Connection problem

I have compiled a stand alone application that connects to our sql server and reads data from the tables, providing searches. I have also compiled the same code as a dll to be used as a command in AutoCAD. But the dll exits at the sql connection string.

The error message is:
Request for permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

The connection string includes the following info:

Initial Catalog
Data Source
Packet Size
User Id
Password

Any ideas? Have I missed something? Why doesnt the dll connect but the exe does?

Thanks,

Kevin.
6 REPLIES 6
Message 2 of 7
ChrisArps
in reply to: Anonymous

This has got to be a sql server security issue, I use jet 4.0 mdb files from dot net and use the same dll from an external exe and inside of ADT/Autocad as well with no problems.

My guess is that the exe correctly builds the proper client info to use sql server and the dll does not.

Chris Arps
Message 3 of 7
Mikko
in reply to: Anonymous

Just tried this with no problems.

Imports Autodesk.AutoCAD.Runtime

Public Class Class1

_
Public Sub AllUsers()
MsgBox(GetUsers().Tables(0).Rows(1).Item(0).ToString)
End Sub

Public Function GetUsers() As DataSet
Dim MyConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection("server=sql-data;uid=YOUR_NAME;pwd=YOUR_PASSWORD;Trusted_Connection=false;database=WorkWithIt")
Dim MyCommand As System.Data.SqlClient.SqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter("SELECT Email FROM Users", MyConnection)
Dim DS As DataSet = New DataSet
MyCommand.Fill(DS, "Users")
MyConnection.Close()
Return DS
End Function

End Class
Message 4 of 7
Anonymous
in reply to: Anonymous

Aha!! It is a security issue (still not solved though). I have just written my first VB.Net code to make a text file and I have encountered a similar error message ... System.Security.Permissions.FileIOPermission, mscorlib ... failed (mscorlib.dll). I'm about to do some searching to see why.
Message 5 of 7
Anonymous
in reply to: Anonymous

File permission problem solved! Havent checked the SQL connection yet though. Here are the details on how to solve:

Find mscorcfg.msc and run it. Then expand as follows:

Runtime Security Policy
- Machine
- Code Groups
- All_Code

Highlight LocalIntranet under All_Code, right click and choose Properties.
Go to the Permission Set tab and choose Full Control.
Message 6 of 7
Anonymous
in reply to: Anonymous

Bingo!!! SQL connection error message solved... now to figure out why there's no data in the controls.... 😞
Message 7 of 7
krishnaeng
in reply to: Anonymous

Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
this error occur even setting the Permission to FullTrust which is availabel in the permission tab

Help me out

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost