If TextBox1.Text = Nothing Or TextBox2.Text = Nothing Or TextBox3.Text = Nothing Or TextBox4.Text = Nothing Or TextBox5.Text = Nothing Or ComboBox1.SelectedItem = Nothing Or ComboBox2.SelectedItem = Nothing Then
MsgBox("User not updated! Please try again", MsgBoxStyle.Critical)
Else
mysqlconn.Open()
cmd.Connection = mysqlconn
cmd.CommandType = CommandType.Text
cmd.CommandText = "UPDATE user SET `Firstname` = @fname, `Lastname` = @lname, `Password` = @pword, `contactno` = @contact, `Username` = @uname, `Subject` = @subject, `Position` = @post, `Gender` = @gender WHERE `ID` = @id"
With cmd.Parameters
.AddWithValue("@ID", "ID")
.AddWithValue("@uname", TextBox3.Text)
.AddWithValue("@fname", TextBox1.Text)
.AddWithValue("@lname", TextBox2.Text)
.AddWithValue("@pword", TextBox4.Text)
.AddWithValue("@contact", TextBox5.Text)
.AddWithValue("@subject", ComboBox1.SelectedItem)
.AddWithValue("@post", ComboBox2.SelectedItem)
If RadioButton1.Checked Then
.AddWithValue("@gender", "Male")
ElseIf RadioButton2.Checked Then
.AddWithValue("@gender", "Female")
End If
End With
cmd.ExecuteNonQuery()
MsgBox("Product Updated Successfully", MsgBoxStyle.OkOnly)
mysqlconn.Close()
我的代码有什么问题吗?它没有更新我的数据库。但消息框表示产品已成功更新且无错误。