thefunnyman
Member
- Joined
- Oct 7, 2009
- Messages
- 5
- Programming Experience
- 3-5
I have a bound datagrid that contains textboxes and comboboxes. I am having problems getting my changes to consistently update the database behind the scenes. I have an EndEdit event that fires everytime it needs to and executes the code to update the database. However, the update commands only seem to care about the first row, with some caveats.
Let me see if I can explain this. The first row updates just fine. I enter text or select a value from the combobox and the endedit event fires and updates the database. If I move to the next row, and do the same thing, the endedit event fires and the code to update the database executes. but, my changes aren't actually saved. I catch no exceptions as a result of this. Here's the kicker. If I change row 2 and then select row 3, then my changes to row 2 are reflected in the database. Basically, I have to change rows when updating any rows other than row 1 in order for my changes to be saved to the database. Below is the relevant code that updates the db. This code is confirmed to fire every time i update a cell anywhere in the datagridview.
Any help would be greatly appreciated. Getting close to the project deadline.
Thanks,
thefunnyman
Let me see if I can explain this. The first row updates just fine. I enter text or select a value from the combobox and the endedit event fires and updates the database. If I move to the next row, and do the same thing, the endedit event fires and the code to update the database executes. but, my changes aren't actually saved. I catch no exceptions as a result of this. Here's the kicker. If I change row 2 and then select row 3, then my changes to row 2 are reflected in the database. Basically, I have to change rows when updating any rows other than row 1 in order for my changes to be saved to the database. Below is the relevant code that updates the db. This code is confirmed to fire every time i update a cell anywhere in the datagridview.
VB.NET:
dgv.EndEdit()
dgv.BindingContext(ds.Tables("dbTable")).EndCurrentEdit()
adapter.Update(ds.Tables("dbTable"))
Any help would be greatly appreciated. Getting close to the project deadline.
Thanks,
thefunnyman