P
Patrick Huffer
I used the Data Form Wizard in Visual Studio to create a form allowing
the user to edit a simple parent table. The parent and child tables
already have a cascade updates relationship in SQL Server on the
parent table's primary key. I accepted all the defaults in the wizard.
A dataset was generated that contains the cascade update relationship.
The form that was generated contains two datagrids, a Load button, and
an Update button. Now, when I run the form and change the data in the
primary key column in the parent table, I get several strange things
happening. First there is a DBConcurrencyException when I try to
update, which occurs on the call to the second (child) dataset's
Update() method. The error reads: "Concurrency violation: the
UpdateCommand affected 0 records". But when I look at the data in SQL
Server, it has been correctly updated. So I think, OK, I can ignore
the concurrency violation error so I catch it and do nothing. This
time when I run the form and change the data in the primary key column
in the parent table, I get a ConstraintException: "Failed to enable
constraints. One or more rows contain values violating non-null,
unique or foreign-key constraints". And the parent table now displays
TWO identical rows, each with the new value that I just entered in the
primary key field. Again the data in both tables is totally correct.
At this point, I gave up.
My question is, under what circumstances can the Data Form Wizard
generate a form for two simple related tables that actually works? Is
there a tutorial out there anywhere that demonstates this?
the user to edit a simple parent table. The parent and child tables
already have a cascade updates relationship in SQL Server on the
parent table's primary key. I accepted all the defaults in the wizard.
A dataset was generated that contains the cascade update relationship.
The form that was generated contains two datagrids, a Load button, and
an Update button. Now, when I run the form and change the data in the
primary key column in the parent table, I get several strange things
happening. First there is a DBConcurrencyException when I try to
update, which occurs on the call to the second (child) dataset's
Update() method. The error reads: "Concurrency violation: the
UpdateCommand affected 0 records". But when I look at the data in SQL
Server, it has been correctly updated. So I think, OK, I can ignore
the concurrency violation error so I catch it and do nothing. This
time when I run the form and change the data in the primary key column
in the parent table, I get a ConstraintException: "Failed to enable
constraints. One or more rows contain values violating non-null,
unique or foreign-key constraints". And the parent table now displays
TWO identical rows, each with the new value that I just entered in the
primary key field. Again the data in both tables is totally correct.
At this point, I gave up.
My question is, under what circumstances can the Data Form Wizard
generate a form for two simple related tables that actually works? Is
there a tutorial out there anywhere that demonstates this?