I'm trying to do a to do list program, but my remove button is not working. Here is my remove button:
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
After I press the remove button, it will only remove from my user interface, but not in my database.
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
NOTE : the msgbox's default button is NO
if you press NO
it wont delete the Entry when msgbox prompt press YES
then the code will pass into delete section then only it will remove from DB
try this if not works come back