从MySQL ADO.NET库切换到MySQL连接器问题 [英] Switching from MySQL ADO.NET libraries to MySQL connector issue
问题描述
由于MySQL库中存在错误,因此我已将C#项目从MySQL ADO.NET库切换到MySQL连接器。
I have switched my C# project from MySQL ADO.NET libraries to MySQL connector since there was a bug in MySQL libraries.
与上述问题有关的上一个问题: StackOverFlow问题
Previous Question related to the aforementioned issue: StackOverFlow Question
我已经使用过 MySql Connector 文档作为切换库的参考。
I have used MySql Connector documentation as the reference for switching libraries.
随着库的更改,现有项目中的MySQL关键字触发了一些新错误。
Following the change of the libraries, there were some new errors triggered for the MySQL keywords in the existing project.
1) MySqlConnection
在私人 MySqlConnection连接中;
行。
错误:表示打开连接到MySQL Server数据库。该
类不能继承。
'MySql.Data'和'MySqlConnector'中都存在类型'MySqlConnection'。
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) MySqlException
在捕获(MySqlException ex)
行中。
错误:当MySQL返回错误时,抛出异常。此类
无法继承。
'MySql.Data'和'MySqlConnector'中都存在类型'MySqlException'。
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)<$ c MySqlCommand cmd = new MySqlCommand();
行中的$ c> MySqlCommand 。
3) MySqlCommand
in MySqlCommand cmd = new MySqlCommand();
line.
错误:表示要对MySQL数据库执行的SQL语句。
此类不能继承。
'MySql.Data'和'MySqlConnector'中都存在类型'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) cmd.Parameters.Add(?jobNo,MySqlDbType.VarChar)中的$ c> MySqlDbType
。Value=(values [0]);
4) MySqlDbType
in cmd.Parameters.Add("?jobNo", MySqlDbType.VarChar).Value = (values[0]);
line.
错误:为MySql.Data.MySqlClient中的
使用字段指定属性的特定于数据的MySQL类型.MySqlParameter。
类型'MySqlDbType'同时存在于'MySql.Data'和'MySqlConnector'中。
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'.
关于如何减轻上述错误?
Any suggestions on how to mitigate the above errors?
推荐答案
主要错误是:
'MySql.Data'和'MySqlConnector'中都存在'MySqlConnection'类型。
The type 'MySqlConnection' exists in both 'MySql.Data' and 'MySqlConnector'.
您的项目同时引用了 MySql.Data.dll
和 MySqlConnector
。使用NuGet软件包管理器卸载 MySql.Data
软件包,并确保从其中删除了 MySql.Data.dll
引用。您的csproj, packages.config
等。
It appears that your project is referencing both MySql.Data.dll
and MySqlConnector
. Uninstall the MySql.Data
package using NuGet Package Manager, and make sure the MySql.Data.dll
reference is removed from your csproj, packages.config
etc.
(在高级方案中,您可以使用外部别名来引用这两个库,但是我强烈建议不鼓励这样做:它可能导致创建两个连接池,启动两个清理线程,等等。)
(In advanced scenarios, you can use an extern alias to reference both libraries, but I would strongly discourage it: it can cause two connection pools to be created, two cleanup threads to be started, etc.)
这篇关于从MySQL ADO.NET库切换到MySQL连接器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!