SQL语法错误似乎可以找到正确的查询


Error in SQL syntax Can seem to find the right query

我遇到了麻烦,我似乎无法使sql查询正确

                Dim command1 As New MySqlCommand("UPDATE userscanner SET Username ='" & txtbox_username.Text & "',Password='" & txtbox_password.Text & "' WHERE ID = '" & lbl_id.Text & "')", Connection)
                command1.ExecuteNonQuery()
                MsgBox("Profile Successfuly Saved")
                Me.Close()

但我有一个错误,上面写着"你的sql语法有错误;请查看coressponds到MySQL服务器版本的手册,在第1行的‘)’附近找到正确的语法

BTW我使用XAMPP和MYSQL作为数据库

您有多余的')'

更正:

            Dim command1 As New MySqlCommand("UPDATE userscanner SET Username ='" & txtbox_username.Text & "',Password='" & txtbox_password.Text & "' WHERE ID = '" & lbl_id.Text & "'", Connection)
            command1.ExecuteNonQuery()
            MsgBox("Profile Successfuly Saved")
            Me.Close()

试试这个:

        Dim command1 As New MySqlCommand("UPDATE userscanner SET Username ='" & txtbox_username.Text & "',Password='" & txtbox_password.Text & "' WHERE ID = '" & lbl_id.Text & "'", Connection)
        command1.ExecuteNonQuery()
        MsgBox("Profile Successfuly Saved")
        Me.Close()

在构建sql语句

时,您似乎包含了一个")"关闭的Paradishesion而没有打开

我认为您需要删除")"。

Dim command1 As New MySqlCommand("UPDATE userscanner SET Username ='" & txtbox_username.Text & "',Password='" & txtbox_password.Text & "' WHERE ID = '" & lbl_id.Text & "'", Connection)

您应该使用参数化更新查询