Mysterious behavior of RowState

  • Thread starter Thread starter Matt Burland
  • Start date Start date
M

Matt Burland

Hi,

I have a form with many controls on it that is bound to a dataset containing
several related tables. The form will display data from one DataRow of a
main table as well as related data from a number of child tables (with 1 to
1 relations). Now I have several problems with the way this thing behaves
that all seem to relate to when (or if) the RowState of the DataRow gets
updated.

1) Changes made to the main table DO NOT update the RowState until I move to
another record

2) Moving to another record seems to set the RowState of the previous record
to Modified regardless of whether it's actually been modified! i.e. the very
act of looking at the thing seems to change it - perhaps the RowState is
imitating Schrodinger's cat!!

3) Changes to the child tables DO NOT EVER change the RowState unless I
manually iterate through all the relations and retrive all the child tables
and call Ended() on them, but that's a lot of looping that I don't think I
would have to do if the thing was working properly.

The problem caused by all of this is that when I try to update the database
it either completely ignores some changes (in the case of the child tables)
or wastes time updating rows that haven't been changed (in the case of the
main table). Also I'd like to be able to indicate to the user that the
record has been changed since they last connected to the database so they
can decide if they need to reconnect or roll back the changes they made.
Any help, thoughts or comments on this would be GREATLY appreciated.

Cheers

Matt
 
Can yopu post the code....what you are experiencing sounds kind of weird for
sure, and it's really hard to tell what's causing all of this without
looking at the code.

HTH,

Bill
 
I'd like to post the code but it rather large and complicated and I'm not
100% sure I know which bits are causing the problems. I might try and
extract the bits I think are relevant later, but it'll take some time.
Nevertheless, I think I have finally nailed down the problem with my quantum
mechanical DataRows (i.e. observing them changes them!). The problem seems
to stem from binding to comboboxes using the "SelectedItem" property instead
of "Text". Apparently if you bind to SelectedItem it automatically write the
(same) value back to the DataSet and causes it to claim to be updated when
it isn't. The problem is, if you bind to the Text property instead it will
display correctly when you look at the record, but if you change it, move to
another record, then move back you find your changes have magically
disappeared. So the question is: what is the right property to bind to on
the combobox? To elaborate, I have strings in my database and I want to have
the binding select the string in the combobox that matches, both
SelectedItem and Text will do this, but both have their unique
problems....sigh
 
Back
Top