1 Replies - 736 Views - Last Post: 05 October 2012 - 01:51 AM Rate Topic: -----

#1 maiOHmai  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 86
  • Joined: 09-July 12

InvalidOperationException problem

Posted 04 October 2012 - 10:30 PM

Good day! i need some help here. :/
here is the scenario:
i searched for record having "a" in their title, it will then show results (i used bindingnavigator in Details). everytime i try to delete records these problems occurred:


First Problem.
if the result is more than one (1), for example it displayed three (3) records and i press the delete button, 2 records that is displayed will be removed, one(1) was removed permanently and the other was removed just from the list.


Second Problem.
if the result is only one (1), then this error occurs "Current item cannot be removed from the list because there is no current item".

Here is the code i'm using:
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click

            If MessageBox.Show("Are you sure you want to delete the current record?", _
                              "Confirm Delete", _
                              MessageBoxButtons.OKCancel, _
                              MessageBoxIcon.Question, _
           MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.OK Then
            End If
        Catch ex As Exception
        End Try
    End Sub

Is This A Good Question/Topic? 0
  • +

Replies To: InvalidOperationException problem

#2 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 233
  • View blog
  • Posts: 770
  • Joined: 19-October 11

Re: InvalidOperationException problem

Posted 05 October 2012 - 01:51 AM

Try adding DataSet3.Fill(DataSet3.TableToFill) after you UpdateAll, because Update only does the work on data source, not on in-memory data. You might need to refresh (reload) bindingsource also.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1