Child DB insert from DataGrid
Hi all
My problem is like this: I have two tables Parents and Childs. The second one has a FK to the PK of the first one. Also, I have a WinForm with a couple of controls and a DataGrid. The idea is to navigate the parents in the form and see his childs in the grid and besides that to create a parent and at the same form an time make available the creation of his childs. Well, i use a dataset and two dataadapters. The dataset also includes a relationship beetween the two tables and the table Parents as a PK AutoNumber named ChildsParents.
I set the property datasource to the dataset and datamember to de Parents table. Set the DataBinding/Text to the columns of DataSet.Parents."name of each column" and the datasource of the grid to the dataset."relationship beetween parents and childs".
When i create the parent makeing a BindingManger.AddNew and saving the Parent with out adding rows in the grid it works grate. After that i come back to that added parent and create his childs with out a problem. But if i complete the fields for the parent and complete the fields for one child and enter to another row it sais this:
"ForeignKeyConstraint ChildsParents requires the child key values to exists in the parent table"
If i show the IDParent in the grid it show it (is not null) but that ID is not in the phisical database, just in the dataset.
Can anybody help me?
Thanks
Lionel