.NET

Reply
Active Contributor
cadmaxza
Posts: 36
Registered: ‎06-23-2004
Message 1 of 7 (138 Views)

SQL Connection problem

138 Views, 6 Replies
01-10-2006 11:24 PM
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.
Distinguished Contributor
ChrisArps
Posts: 311
Registered: ‎07-29-2004
Message 2 of 7 (138 Views)

Re: SQL Connection problem

01-17-2006 04:49 AM in reply to: cadmaxza
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
Distinguished Contributor
Mikko
Posts: 212
Registered: ‎10-03-2003
Message 3 of 7 (138 Views)

Re: SQL Connection problem

01-17-2006 05:27 AM in reply to: cadmaxza
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
Active Contributor
cadmaxza
Posts: 36
Registered: ‎06-23-2004
Message 4 of 7 (138 Views)

Re: SQL Connection problem

02-01-2006 04:51 AM in reply to: cadmaxza
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.
Active Contributor
cadmaxza
Posts: 36
Registered: ‎06-23-2004
Message 5 of 7 (138 Views)

Re: SQL Connection problem

02-01-2006 05:47 AM in reply to: cadmaxza
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.
Active Contributor
cadmaxza
Posts: 36
Registered: ‎06-23-2004
Message 6 of 7 (138 Views)

Re: SQL Connection problem

02-01-2006 05:57 AM in reply to: cadmaxza
Bingo!!! SQL connection error message solved... now to figure out why there's no data in the controls.... :-(
New Member
krishnaeng
Posts: 1
Registered: ‎01-09-2008
Message 7 of 7 (138 Views)

Re: SQL Connection problem

01-09-2008 09:47 PM in reply to: cadmaxza
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
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.