0

I am getting an error every time use the delete button. I am using Visual basics 2008 and micrsoft access 2007 as a database. the way this should work is that i search the customer i want to delete i press the delete button and done. its removed from the program and database.

this is the code

Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
    Dim Answer As DialogResult
    Dim Count As Integer
    Count = SandRDataSet.Tables("Customer details").Rows.Count
    If Count = 0 Then
        MessageBox.Show("There are no records to delete", "Delete record", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Else
        Answer = MessageBox.Show("Are you sure ou want to delete.", "Delete record", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If Answer = Windows.Forms.DialogResult.Yes Then
            SandRDataSet.Tables("Customer details").Rows(CurrentRowNo).Delete()


            da.Update(SandRDataSet, "Customer details")
            MessageBox.Show("The record has been deleted", "Delete record", MessageBoxButtons.OK, MessageBoxIcon.Information)
            CurrentRowNo = ds.Tables("Customer details").Rows.Count - 1
        Else
            MessageBox.Show("The record has NOT been deleted.", "Delete record", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If
    End If
End Sub

but when i use the code, i get the error message as "Update requires a valid DeleteCommand when passed DataRow collection with deleted rows.".Any help will be Appreciated.

akhil kumar
  • 1,598
  • 1
  • 13
  • 26

0 Answers0