M
Mika M
Hello!
I'm using a dataset to manage SQL db. I created two tables into DataSet
(Headers and Items), I fill them with data, and I make relation between them
like (Headers-table column ID (AutoNumber) (int) to Items-table column
HeaderID (int)) ...
ds.Relations.Add(New DataRelation("Items",
ds.Tables("Headers").Columns("ID"), ds.Tables("Items").Columns("HeaderID")))
.... then I have bound Headers DataTable into TextBoxes and Items DataTable
into Grid.
So far application I working well, but when I add a new record (this only
happends when trying to add new records) after clicking 'New'-button ...
..EndCurrentEdit()
..AddNew()
.... I fill TextBoxes bound to parent DataTable, and then try to insert a new
row to the grid, I'll get the following error...
"ForeignKeyConstraint Items requires the child key values (2) to exist in
the parent table."
I know I don't have a datarow in parent DataTable with a primary key value
of 2 yet, but I think it must be possible to fill both TextBoxes and Grid
before saving (insert) these into database.
I hope to have explained well the problem.
I'm using a dataset to manage SQL db. I created two tables into DataSet
(Headers and Items), I fill them with data, and I make relation between them
like (Headers-table column ID (AutoNumber) (int) to Items-table column
HeaderID (int)) ...
ds.Relations.Add(New DataRelation("Items",
ds.Tables("Headers").Columns("ID"), ds.Tables("Items").Columns("HeaderID")))
.... then I have bound Headers DataTable into TextBoxes and Items DataTable
into Grid.
So far application I working well, but when I add a new record (this only
happends when trying to add new records) after clicking 'New'-button ...
..EndCurrentEdit()
..AddNew()
.... I fill TextBoxes bound to parent DataTable, and then try to insert a new
row to the grid, I'll get the following error...
"ForeignKeyConstraint Items requires the child key values (2) to exist in
the parent table."
I know I don't have a datarow in parent DataTable with a primary key value
of 2 yet, but I think it must be possible to fill both TextBoxes and Grid
before saving (insert) these into database.
I hope to have explained well the problem.