开发者

Request for the permission of type 'System.Data.Odbc.OdbcPermission.. help needed

开发者 https://www.devze.com 2022-12-25 13:37 出处:网络
I\'m getting the following error when trying to connect to a remote my开发者_运维技巧sql server.

I'm getting the following error when trying to connect to a remote my开发者_运维技巧sql server.

Request for the permission of type 'System.Data.Odbc.OdbcPermission, 
System.Data, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089' failed.

I've installed the odbc 5.1 driver, and can connect to the database using the Data Sources (ODBC) tool in Control Panel.

However when I try and run my C# scrip to connect, I get the above error.

I've read its something to do with trust levels or something? I don't quite understand what people were talking about though. I went to C:... Framework/v2.0.50727/CONFIG and added <IPermission class="OdbcPermission" version="1" Unrestricted="true"/> to the medium and high trust.config files, but that didn't help..

Can someone help me out here please?

My connection string is

MyConString = "DRIVER={MySQL ODBC 5.1 Driver};" +
                "SERVER=" + m_strHost + ";" +
                "PORT=3306;" +
                "DATABASE=" + m_strDatabase + ";" +
                "UID=" + m_strUserName + ";" +
                "PWD=" + m_strPassword + ";" +
                "OPTION=3;";


I would recommend using the .NET Connector instead of the ODBC driver. I only use the ODBC driver for VBA/Microsoft Access connections. With the .NET connector I have not had any connection issues similar to what you describe.

0

精彩评论

暂无评论...
验证码 换一张
取 消