+ Reply to Thread
Results 1 to 1 of 1

Thread: Delete record problems in VB.Net/SQL Server app

  1. #1
    AveryHilditch is offline VB.NET Forum Newbie AveryHilditch is on a distinguished programming path ahead
    .NET Framework
    .NET 3.5
    Join Date
    Feb 2010
    Location
    Adelaide, South Australia
    Age
    59
    Posts
    4
    Reputation
    0

    Default Delete record problems in VB.Net/SQL Server app

    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).

    Code:
    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.
    Last edited by AveryHilditch; 02-04-2010 at 9:49 PM. Reason: Copied the wrong code

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts