它没有显示任何错误并告诉我它已保存。如果我用数据库中的实际值替换userlable.text
,它就可以工作。但是userlable.text
它不起作用。我在另一个vb.form上做了类似的事情并且它工作了,为什么不这样呢?它不会在用户名所在的行的T1Marks中更新,但它表示它有效。有什么帮助吗?
Private Sub Finish1Button_Click(sender As Object, e As EventArgs) Handles Finish1Button.Click
con = New MySqlConnection
con.ConnectionString = "server=localhost;userid=root;password=Red-grape01;database=math"
Try
con.Open()
Dim Order As String
Order = "update math.marks set T1Marks='" & MarkLable.Text & "' WHERE Username='" & userlabel.Text & "'"
cmd = New MySqlCommand(Order, con)
datareader = cmd.ExecuteReader
MessageBox.Show("Saved")
con.Close()
Catch ex As MySqlException
MessageBox.Show("Error")
Finally
con.Dispose()
End Try
ExamTopicSelectionPage.Show()
Me.Close()
End Sub