请求类型 'System.Data.Odbc.OdbcPermission.. 需要帮助

发布于 2024-08-27 07:39:38 字数 886 浏览 1 评论 0原文

当尝试连接到远程 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

书间行客 2024-09-03 07:39:38

我建议使用 .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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文