0
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(从数据库中删除后)

谢谢

4

1 回答 1

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
于 2012-07-12T07:37:24.110 回答