Groups | Blog | Home
all groups > vb.net data > july 2004 >

vb.net data : Error recovery during AddNew


Gary Shell
7/14/2004 11:18:25 AM
I have a simple data form that can edit and add records to a table. In my
"OK Button" code I EndCurrentEdit and then perform a UPDATE method on the
data adapter. It works just fine adding and editing data.

One field on the table is a foreign key and I have referential integrity
enforced on the server. When adding a new record I catch the exception
raised by the Update method if the user supplies invalid data and display an
error message. I then allow the user to fix the problem and hit the OK
button again. The problem is when I get to the Update method again the
underlying row in the dataset seems to be no longer bound to my controls.
That is, if I go in and look at the contents of the item collection for the
row being added the field that triggered the exception is still null. It
does not have the value in the control that the user just corrected.

Is there something I need to tell the dataset or more likely the data
adapter that we are "retrying" the update?

Sign me somewhat confused, but impressed, by this .Net databinding.

Gary

W.G. Ryan [eMVP]
9/7/2004 7:10:40 PM
Check the rowstate of the rows - make sure HasChanges is set to true.
[quoted text, click to view]

AddThis Social Bookmark Button