Dim iReturn As Boolean
Using SQLConnection As New MySqlConnection(strMySqlConnectionString)
Using sqlCommand As New MySqlCommand
With sqlCommand
.CommandText = "UPDATE user" & "SET FirstName = @FirstName" & "From user" & "WHERE Username = @Username;"
.Connection = SQLConnection
.CommandType = CommandType.Text '// You missed this line
.Parameters.AddWithValue("@FirstName", editFirsName.Text)
.Parameters.AddWithValue("@Username", editusername.Text)
End With
Try
SQLConnection.Open()
sqlCommand.ExecuteNonQuery()
iReturn = True
MsgBox("User Was Update succesfully")
Catch ex As MySqlException
MsgBox(ex.Message.ToString)
iReturn = False
Finally
SQLConnection.Close()
End Try
End Using
End Using
If iReturn = False Then
End If
我从上面的代码中收到以下错误:
命令执行期间遇到致命错误。
答案 0 :(得分:0)
您的SQL更新语法显示不正确。
更改:强>
.CommandText = "UPDATE user" & "SET FirstName = @FirstName" & "From user" & "WHERE Username = @Username;"
要强>
.CommandText = "UPDATE user SET FirstName = @FirstName WHERE Username = @Username;"