F
Flomo Togba Kwele
I created a form, a datasource (Product table from AdventureWorks)
from the Data Sources tab, and dragged the Product table from the Data
Source tab to the form's designer surface.
This created a dataset, bindingsource, tableadapter and
bindingnavigator.
I placed the following code in the click event of the delete button on
the bindingnavigator:
Me.Validate()
Me.ProductBindingSource.EndEdit()
Me.ProductTableAdapter.Update(Me.AdventureWorksDataSet.Product)
When running the app, I select a row and click the delete button on
the navigator. It disappears. However, when I exit the app and
re-enter, the row is still there.
As another test, if I select the row again, and click the delete
button, and click it once more, the row is actually deleted from the
database.
In debug I place a stop after the Validate method above. The
underlying dataset shows false for HasChanges after the first click of
the delete button and the selected row shows Unchanged for its
RowState.
However, after the 2nd click of the delete button, the dataset shows
true for HasChanges and Deleted for the RowState associated with the
row.
What is wrong with my code?
Thanks
from the Data Sources tab, and dragged the Product table from the Data
Source tab to the form's designer surface.
This created a dataset, bindingsource, tableadapter and
bindingnavigator.
I placed the following code in the click event of the delete button on
the bindingnavigator:
Me.Validate()
Me.ProductBindingSource.EndEdit()
Me.ProductTableAdapter.Update(Me.AdventureWorksDataSet.Product)
When running the app, I select a row and click the delete button on
the navigator. It disappears. However, when I exit the app and
re-enter, the row is still there.
As another test, if I select the row again, and click the delete
button, and click it once more, the row is actually deleted from the
database.
In debug I place a stop after the Validate method above. The
underlying dataset shows false for HasChanges after the first click of
the delete button and the selected row shows Unchanged for its
RowState.
However, after the 2nd click of the delete button, the dataset shows
true for HasChanges and Deleted for the RowState associated with the
row.
What is wrong with my code?
Thanks