R
Rui Gon?alves via .NET 247
Hi,
This is a strange problem...
I have a Access database with 2 tables, a master with 1 primary key (pk) and a child with 2 pk's.
One client can have one or more orders.
Clients
*id
name
Orders
*fkClient
*id
units
price
So far so good.
I created in VS2003 using the "DataForm Wizard" a simple master-detail form with the "Single record with individual controls" option. (I only have this problem with this option, there's no problem with to data grids).
This creates a simple data form with some text boxes and a data grid, witch is ok view data..
The problem is, when i add a new record (this only happends to the new added records) and when a insert a new row on the data grid I get the folowing error
"Error when commiting the row to the original data store :
ForeignKeyConstraint rel_FKClient_ID requires a child key value (1) to exist in the parent table. Do you want to correct the value?"
The dataset is MyDS and the relation is parent.id to client.fkClient.
I beliave that this is due to the fact that the new created record does not yet exist in the parent dataset.
But why!? Instead of having individual controls if I put 2 datagrid, one for the parent and the one for the child, this problem does not exist.
I have tried to put an autoincrement, just for testing, and when i add a new row to the orders datagrid the correct client id appears, but the problem remains.
How can I overcome this without having to update the dataset before adding a new row to the child datagrid.
Please share some information, cause I'm freaking out.......
Thanks to all.
This is a strange problem...
I have a Access database with 2 tables, a master with 1 primary key (pk) and a child with 2 pk's.
One client can have one or more orders.
Clients
*id
name
Orders
*fkClient
*id
units
price
So far so good.
I created in VS2003 using the "DataForm Wizard" a simple master-detail form with the "Single record with individual controls" option. (I only have this problem with this option, there's no problem with to data grids).
This creates a simple data form with some text boxes and a data grid, witch is ok view data..
The problem is, when i add a new record (this only happends to the new added records) and when a insert a new row on the data grid I get the folowing error
"Error when commiting the row to the original data store :
ForeignKeyConstraint rel_FKClient_ID requires a child key value (1) to exist in the parent table. Do you want to correct the value?"
The dataset is MyDS and the relation is parent.id to client.fkClient.
I beliave that this is due to the fact that the new created record does not yet exist in the parent dataset.
But why!? Instead of having individual controls if I put 2 datagrid, one for the parent and the one for the child, this problem does not exist.
I have tried to put an autoincrement, just for testing, and when i add a new row to the orders datagrid the correct client id appears, but the problem remains.
How can I overcome this without having to update the dataset before adding a new row to the child datagrid.
Please share some information, cause I'm freaking out.......
Thanks to all.