我正在尝试执行列表程序,但我的删除按钮无效。这是我的删除按钮:
Private Sub btnremove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnremove.Click
If MessageBox.Show("Do you really want to remove this task?", _
"Remove", MessageBoxButtons.YesNo, _
MessageBoxIcon.Warning) = DialogResult.No Then
MsgBox("Operation Cancelled")
Exit Sub
End If
Dim cb As New OleDb.OleDbCommandBuilder(da)
con.Open()
ds.Tables("todolist").Rows(inc).Delete()
MaxRows = MaxRows - 1
ds.AcceptChanges()
con.Close()
inc = 0
NavigateRecords()
da.Update(ds, "todolist")
End Sub
按下删除按钮后,它只会从我的用户界面中删除,但不会从我的数据库中删除。
答案 0 :(得分:0)
Private Sub btnremove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnremove.Click
If MessageBox.Show("Do you really want to remove this task?", _
"Remove", MessageBoxButtons.YesNo, _
MessageBoxIcon.Warning) = DialogResult.No Then
MsgBox("Operation Cancelled")
Else
Dim cb As New OleDb.OleDbCommandBuilder(da)
con.Open()
ds.Tables("todolist").Rows(inc).Delete()
MaxRows = MaxRows - 1
ds.AcceptChanges()
con.Close()
inc = 0
NavigateRecords()
da.Update(ds, "todolist")
End If
End Sub
注意:msgbox的默认按钮是NO
,如果按NO
它不会在msgbox提示符press YES
时删除条目,然后代码将进入删除部分,然后只有它将从DB
尝试这个,如果没有作品回来