I seem to have a problem with the following code:
the follow code is in a click event of a new button:
Code:
sqlBindingSource.AddNew()
the follow code is in a click event of a delete button:
Code:
Try If MessageBox.Show("Delete?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then sqlDs.Tables("Items").Rows(sqlBindingSource.Position).Delete() Dim slqCmdBuilder As New SqlCommandBuilder(sqlAdapter) Me.sqlAdapter.Update(Me.sqlDs.Tables("Items")) slqCmdBuilder.Dispose() slqCmdBuilder = Nothing End If Catch ex As Exception MessageBox.Show(ex.Message, "Error Occurred", MessageBoxButtons.OK, MessageBoxIcon.Error) Me.sqlDs.Tables("Items").RejectChanges() End Try
my problem is that every time i add 5 row to bindingsource through bindingnavigator and then try to delete one of the i get an error "There is no row at position X". can anyone plz help?


Reply With Quote
