vb.net MySqlConnection' 在命名空间 'MySql.Data.MySqlClient [Visual Basic -VS2008] 中不明确

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21977845/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 16:52:52  来源:igfitidea点击:

MySqlConnection' is ambiguous in the namespace 'MySql.Data.MySqlClient [Visual Basic -VS2008]

mysqlvb.net

提问by Alecsx MKD

I'm trying to make a connection to a database [MySql] on localhost but I have a problem ....

我正在尝试与本地主机上的数据库 [MySql] 建立连接,但我遇到了问题......

This is the code : (it's a class called ConnectDateBase.vb...)

这是代码:(这是一个名为 ConnectDateBase.vb 的类...)

Imports MySql.Data.MySqlClient

Public Class ConnectDateBase

    Public Class MySQLConnect
        Public db_con As New MySqlConnection
        Private Sub connect()
            Dim dbname As String = "DBNAME"
            Dim dbhost As String = "localhost"
            Dim user As String = "root"
            Dim pass As String = "DBPASSWORD"


            If Not db_con Is Nothing Then db_con.Close()
            db_con.ConnectionString = String.Format("server={0}; user id={1}; password={2}; database={3}; pooling=false", dbhost, user, pass, dbname)

            Try
                db_con.Open()
            Catch ex As MySqlException
                MsgBox("Database Error:[" & ex.Message & "]")
            End Try
        End Sub
    End Class

This is my problem: Error List ->

这是我的问题:错误列表->

  1. MySqlConnection' is ambiguous in the namespace 'MySql.Data.MySqlClient
  2. MySqlException' is ambiguous in the namespace 'MySql.Data.MySqlClient [Errors have identical type]
  1. MySqlConnection' 在命名空间 'MySql.Data.MySqlClient 中是不明确的
  2. MySqlException' 在命名空间 'MySql.Data.MySqlClient 中是不明确的 [错误具有相同的类型]

I tried to add reference but i don't know what reference to add...( Mysql.web or Mysql.data) both failed ... As OS I'm using : windows xp sp3 with NET Framework 3.5 and MySql Connector NET 6.8.3 installed. Know anyone how to fix this (logical error ) please ...

我试图添加引用,但我不知道要添加什么引用......(Mysql.web 或 Mysql.data)都失败了......作为我使用的操作系统:windows xp sp3 with NET Framework 3.5 和 MySql Connector NET 6.8.3 安装。知道任何人如何解决这个(逻辑错误)请...

采纳答案by har07

It seems that compiler get confused because there are several assembly references containing same namespace. Try to remove all references related to MySql, then add reference only to Mysql.data.dll.

编译器似乎很困惑,因为有几个程序集引用包含相同的命名空间。尝试删除与 MySql 相关的所有引用,然后仅添加对Mysql.data.dll.