Wrox Home  
Search P2P Archive for: Go

  Return to Index  

ado_dotnet thread: Problem with Saving Changes on Databinded Controls


Message #1 by "Raizan Rahmat" <raizan@s...> on Sat, 28 Dec 2002 06:56:22
Dear Friends,

I emailed this to feedback@w... While waiting for reply, I will be 
grateful if anyone else with the VB.Net (2nd Edition) book can help. 
Thanks.

....
 I will be grateful if you can help me with this 
problem I'm facing while trying to follow the "Saving 
Changes" example you wrote on pages 579 to 581 of Chapter 16 
(Data Binding) of the abovementioned book.

Problem: What I tried was to follow closely the 
example you set, unfortunately the changes made to the 
comboBox and numericUpDown controls were not saved (there 
are neither syntax nor run-time errors, simply changes 
are not reflected after saving). 

Page 579
Under the 'columnChanged' sub, there is this 
statement:
>> e.row.AcceptChanges()
and accompanying that some explanation and caution to 
its difference in property as opposed to dataGrid. So 
I am wondering if anything is missing.

So I added the statement:
>> e.row.EndEdit()
before
>> e.row.AcceptChanges()

But to no avail. Upon checking the rowState however, 
with the following code:
>> MsgBox("Before: " & e.Row.RowState.ToString)
>> e.Row.EndEdit()
>> MsgBox("After: " & e.Row.RowState.ToString)
>> e.Row.AcceptChanges()
>> MsgBox("Final: " & e.Row.RowState.ToString)
I noticed that there are changes. The code above 
returned me:
>> Before: Unchanged
>> After: Modified
>> Final: Unchanged
I believe this proves that the changes made are 
already updated to the _authors table in your example. 
Despite this, changes are still not saved on implementing 
'saveChanges' on page 581. I tried placing a try and 
catch around the line:
>> adapter.update(_authors)
No error was returned either.

I suspected next the problem was due to the fact that 
I used comboBox control and numericUpDown control to 
bind my data to (for my own validity checks.) The book 
used textBox control. I am hoping that this is not the 
reason for the problem since validity checks and 
controlled entris are quite important in my application.

For your information, my own 'updateBindings()' sub 
that I followed closely to yours had no problems either. 
Data loading works well. Furthermore, I have no 
problems saving changed cell data in the dataGrid example of 
the book, only the forms/textBox one.

Glad if you can help. Thanks.
...

  Return to Index