请求类型 'System.Data.Odbc.OdbcPermission.. 需要帮助
当尝试连接到远程 mysql 服务器时,出现以下错误。
Request for the permission of type 'System.Data.Odbc.OdbcPermission,
System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.
我已经安装了 odbc 5.1 驱动程序,并且可以使用控制面板中的数据源 (ODBC) 工具连接到数据库。
但是,当我尝试运行 C# 脚本进行连接时,出现上述错误。
我读过它与信任级别有关或其他什么?我不太明白人们在谈论什么。我转到 C:... Framework/v2.0.50727/CONFIG 并将
添加到中和高trust.config 文件,但这没有帮助..
有人可以帮我吗?
我的连接字符串是
MyConString = "DRIVER={MySQL ODBC 5.1 Driver};" +
"SERVER=" + m_strHost + ";" +
"PORT=3306;" +
"DATABASE=" + m_strDatabase + ";" +
"UID=" + m_strUserName + ";" +
"PWD=" + m_strPassword + ";" +
"OPTION=3;";
I'm getting the following error when trying to connect to a remote mysql 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;";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用 .NET Connector 而不是 ODBC 驱动程序。我仅使用 ODBC 驱动程序进行 VBA/Microsoft Access 连接。使用 .NET 连接器,我没有遇到任何与您所描述的类似的连接问题。
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.