Private Sub btn_remove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_remove.Click
Dim Query As String
mysqlconn.Open()
Query = "delete from table where screen_id='" & cmb_id.Text & "' "
Dim cmd As MySqlCommand = New MySqlCommand(Query, mysqlconn)
Dim i As Integer = cmd.ExecuteNonQuery()
If (i > 0) Then
MsgBox("Record is Successfully deleted")
Else
MsgBox("Record is not deleted")
End If
mysqlconn.Close()
End Sub
我从组合框中选择id。取决于我从数据库中删除所选的id。以上代码解释相同,但我想在运行时(从数据库删除后)从组合框中删除已删除的id
感谢
答案 0 :(得分:1)
解决方案很简单。删除id后再次加载组合框中的数据..
Private Sub btn_remove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_remove.Click
Dim Query As String
mysqlconn.Open()
Query = "delete from table where screen_id='" & cmb_id.Text & "' "
Dim cmd As MySqlCommand = New MySqlCommand(Query, mysqlconn)
Dim i As Integer = cmd.ExecuteNonQuery()
If (i > 0) Then
MsgBox("Record is Successfully deleted")
**===> load the data here or call the function that load the data in the combo box**
Else
MsgBox("Record is not deleted")
End If
mysqlconn.Close()
End Sub