Delete record problems

AveryHilditch

New member
Joined
Feb 4, 2010
Messages
4
Location
Adelaide, South Australia
Programming Experience
10+
I am developing a VB.Net application using Visual Studio 2008 (VB) and SQL Server 2008 Express.

I have a table with (say) 7 records in it. If I select a record and then hit delete, the record is deleted but the counter shows that 2 have been deleted.

If I have 1 record in the table, an exception is thrown saying that I have no record selected.

The RemoveCurrent line only appears once in the code. Setting a breakpoint shows that the code is only executed once.

This happens on all dialogs connected to any of the tables in the database, all of which have primary keys defined.

The code snippet below is the code I am using (auto-generated by VS).

VB.NET:
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click 
		If MessageBox.Show("Delete", "Delete", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

           TblDocumentsBindingSource.RemoveCurrent() 
           TblDocumentsTableAdapter.Update(FilingRegisterDataSet) 
 End if
End Sub

If I remove the check to confirm deletion the problem doesn't occur.

Attached image shows what I mean.
DatabaseError.gif
 
Last edited:
Back
Top