我正在 Visual Studio 2010 中编写 C# 程序作为 Excel 宏。我正在尝试将程序连接到 MySql 数据库。当我尝试构建时,出现如下错误:
The type or namespace name 'MySql' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'MySqlConnection' could not be found (are you missing a using directive or an assembly reference?)
我已经下载了 .NET MySql 连接器并添加了对 MySql.Data.dll 的 Visual Studio 引用,并且我已经“使用 MySql.Data.MySqlClient;”在我的程序的顶部。这两件事似乎是互联网上看到这些错误的其他所有人的挂断。
为什么我会收到这些错误,我该如何解决?
编辑: 此外,当我键入 using 语句时,IDE 不会为我自动完成 MySql;它似乎不知道它是什么/在哪里。
除了上面显示的 using 语句外,我在尝试使用 MySqlConnection 时遇到错误,例如如下
public Dictionary <string, MySqlConnection> m_envToCon;
最佳答案
我遇到了这个错误,必须在 devenv 构建之前按名称显式删除连接。
<remove name="connectionName" />
在connection add tag前添加以上语句
<connectionStrings>
<remove name="MySql" />
<add name="MySql" connectionString="..." />
<remove name="MySqlConnection" />
<add name="MySqlConnection" connectionString="..." />
</connectionStrings>
关于c# - 无法将 MySql 添加到 C# 程序(引用和 "using"已添加),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31597143/