【问题标题】:An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll vb .netSystem.Data.dll vb .net 中出现“System.ArgumentException”类型的未处理异常
【发布时间】:2025-12-26 11:40:12
【问题描述】:

我是 vb .net 编程的新手,当我尝试将表单按钮连接到 MySql 数据库时遇到以下错误:

“System.ArgumentException”类型的未处理异常发生在 System.Data.dll 附加信息:不支持关键字。

我一直在努力解决这个错误,但我没有成功。请参阅我的以下课程代码:

Imports MySql.Data.MySqlClient
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim connect As New MySqlConnection
        Dim connecto As String = "Server=localhost; User Id=root; Password; Database=sist"
        connect.ConnectionString = connecto
        Try
            connect.Open()
            MessageBox.Show("Connected Successfully")
        Catch ex As MySqlException
            MessageBox.Show(ex.Message)
        End Try
    End Sub
End Class

【问题讨论】:

    标签: vb.net exception unhandled


    【解决方案1】:

    检查您的连接字符串。根据this 应该是这样的:

    Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
    

    所以在你的情况下:

    Dim connecto As String = "Server=localhost; Uid=root; Pwd=yourPassword; Database=sist"
    

    【讨论】:

      最近更新 更多