gpt4 book ai didi

c# - 从 MySQL ADO.NET 库切换到 MySQL 连接器问题

转载 作者:太空宇宙 更新时间:2023-11-03 11:28:11 25 4
gpt4 key购买 nike

由于 MySQL 库中存在错误,我已将我的 C# 项目从 MySQL ADO.NET 库切换到 MySQL 连接器。

与上述问题相关的上一个问题:StackOverFlow Question

我用过MySql Connector文档作为切换库的引用。

随着库的更改,现有项目中的 MySQL 关键字触发了一些新的错误。

1) MySqlConnection私底下MySqlConnection connection;行。

Error: Represents an open connection to a MySQL Server database. This class cannot be inherited. The type 'MySqlConnection' exists in both 'MySql.Data' and 'MySqlConnector'.

2) MySqlExceptioncatch (MySqlException ex)行。

Error: The Exception is thrown when MySQL returns an error. This class cannot be inherited. The type 'MySqlException' exists in both 'MySql.Data' and 'MySqlConnector'.

3) MySqlCommandMySqlCommand cmd = new MySqlCommand();行。

Error: Represents a SQL Statement to execute against a MySQL database. This class cannot be inherited. The type 'MySqlCommand' exists in both 'MySql.Data' and 'MySqlConnector'.

4) MySqlDbTypecmd.Parameters.Add("?jobNo", MySqlDbType.VarChar).Value = (values[0]);行。

Error: Specifies MySQL specific data type of a field, property, for use in a MySql.Data.MySqlClient.MySqlParameter. The type 'MySqlDbType' exists in both 'MySql.Data' and 'MySqlConnector'.

关于如何减轻上述错误的任何建议?

最佳答案

主要错误是:

The type 'MySqlConnection' exists in both 'MySql.Data' and 'MySqlConnector'.

您的项目似乎同时引用了 MySql.Data.dllMySqlConnector。使用 NuGet 包管理器卸载 MySql.Data 包,并确保 MySql.Data.dll 引用已从您的 csproj、packages.config 等等

(在高级场景中,您可以使用 extern alias 来引用这两个库,但我强烈反对:它会导致创建两个连接池、启动两个清理线程等)

关于c# - 从 MySQL ADO.NET 库切换到 MySQL 连接器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52416026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com