每次使用删除按钮时都会出错。我使用Visual Basic 2008和micrsoft access 2007作为数据库。 这应该工作的方式是我搜索我要删除的客户我按下删除按钮并完成。将其从程序和数据库中删除。
这是代码
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
但是当我使用代码时,我收到错误消息为"Update requires a valid DeleteCommand when passed DataRow collection with deleted rows."
。任何帮助都会被感谢。