|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Enforcing parent-child constraintsI 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 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 -- Show quote____________________________________ 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. __________________________________ "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 > |
|||||||||||||||||||||||