Enforcing parent-child constraints

D

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
 
W

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.
__________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top