Home All Groups Group Topic Archive Search About

Enforcing parent-child constraints

Author
8 Dec 2004 11:44 PM
Danny Liberty
Hi,

I have a simple windows forms application which resembles a
parent-child table relationship. To be more specific, the form is bound
to a table called "Sales" and it also contains a datagrid which is
bound to a "SalesDetail" table. When I add a new record to the form and
then try to add a new record the sales detail grid, I get a constraint
error since the parent row dosen't "exist" yet (the dataset hasn't been
updated). One way I've found of solving this is disabling constraints
on the dataset, but this seems like a workaround. I could also update
the dataset with the parent row before the user adds the childs row via
the datagrid, but this also seems wrong since I shouldn't be updating
the dataset until the user actually hits update.
Any suggestions ? Is there a "classical" solution to this type of
problem ?

Thanks in advance !

Danny

Author
9 Dec 2004 2:36 AM
William (Bill) Vaughn
Perhaps the whitepaper I wrote about handling parent/child identity issues
(Managing an @@Identity crisis) would help. See
http://www.betav.com/msdn_magazine.htm

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Show quote
"Danny Liberty" <dlibe***@gmail.com> wrote in message
news:1102549494.966729.279040@f14g2000cwb.googlegroups.com...
> Hi,
>
> I have a simple windows forms application which resembles a
> parent-child table relationship. To be more specific, the form is bound
> to a table called "Sales" and it also contains a datagrid which is
> bound to a "SalesDetail" table. When I add a new record to the form and
> then try to add a new record the sales detail grid, I get a constraint
> error since the parent row dosen't "exist" yet (the dataset hasn't been
> updated). One way I've found of solving this is disabling constraints
> on the dataset, but this seems like a workaround. I could also update
> the dataset with the parent row before the user adds the childs row via
> the datagrid, but this also seems wrong since I shouldn't be updating
> the dataset until the user actually hits update.
> Any suggestions ? Is there a "classical" solution to this type of
> problem ?
>
> Thanks in advance !
>
> Danny
>

AddThis Social Bookmark Button