I have a parent table that has one child table. The parent has a single
field (ID, AutoIncrement, Seed 0, Step -1 in the DataSet, Seed 1, step
1, in DataSource). The child is linked to this ID column in the parent.
I have the parent fields in textboxes and the child is a DataGrid. When
I add a new parent record, then go to add child records, I am getting an
exception that says, "ForeignKeyConstraint requires the child key values
(0) to exist in the parent table. Do you want to correct the value?" ..
I've tried multiple things to fix this, and it doesn't seem to work
right. The first thing I did was make sure I did a EndCurrentEdit when
entering the grid. Well, that helped.. However, the ID of the parent and
Child were both 0, and when it saved it to the datasource, the ID of the
parent changed and all the child records were lost. So, I then added
code to the entering event to endcurrentedit and then Update so that the
real ID would show up. Then I started to get that child key values error
again. So in the Entering event I added the code to set the default
value of the ID column in the child to the new parent ID. I still get
the same error. If I save the parent, navigate off that record and then
back to it, I can enter in child records all day, it works fine, even
without all the entering even code.. It's just on new records. What else
do I have to do here?
Thanks
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.