Relation Grand-parent/Grand-child in a typed DataSet

O

olrt

Hello !
I'm writing a very simple Windows App in C# with Visual Studio 2005.
I have a DataSet composed like this :

DataTable CLIENT
DataTable COMMANDE
DataTable ARTICLE

Relation FK_CLIENT_COMMANDE : 1 CLIENT to many COMMANDE
Relation FK_COMMANDE_ARTICLE : 1 COMMANDE to many ARTICLE

I have implemented 3 DataGridViews :
DataGridView : DgCLIENT bound to CLIENT
DataGridView : DgCOMMAND (detail of DgCLIENT) bound to
FK_CLIENT_COMMANDE
DataGridView : DgARTICLE (detail of DgCOMMAND) bound to
FK_COMMANDE_ARTICLE

My problem :

BidonDataSetPoub ds = (BidonDataSetPoub)bidonDataSetPoub.GetChanges();

aRTICLETableAdapter.Update(ds.ARTICLE.Select("","",DataViewRowState.Deleted));
cOMMANDETableAdapter.Update(ds.COMMANDE.Select("","",DataViewRowState.Deleted));
cLIENTTableAdapter.Update(ds.CLIENT.Select("", "",
DataViewRowState.Deleted));

cLIENTTableAdapter.Update(ds.CLIENT.Select("","",DataViewRowState.ModifiedCurrent));
cOMMANDETableAdapter.Update(ds.COMMANDE.Select("","",DataViewRowState.ModifiedCurrent));
aRTICLETableAdapter.Update(ds.ARTICLE.Select("","",DataViewRowState.ModifiedCurrent));

cLIENTTableAdapter.Update(ds.CLIENT.Select("", "",
DataViewRowState.Added));
cOMMANDETableAdapter.Update(ds.COMMANDE.Select("", "",
DataViewRowState.Added));
aRTICLETableAdapter.Update(ds.ARTICLE.Select("", "",
DataViewRowState.Added));

bidonDataSetPoub.Merge(ds, false);
bidonDataSetPoub.AcceptChanges();

------------------------------------------------------
 
O

olrt

Oops I forgot to describe my problem :)
Let's say I add a CLIENT row in DgCLIENT
And a COMMANDE row in DgCOMMANDE
And a ARTICLE row in DgARTICLE

The ARTICLE row won't be created in the DB.
Now, if the COMMANDE row is already created in the DB, and if a add an
ARTICLE row in DgARTICLE, the ARTICLE row is created in the DB.

Can someonehelp ?
 
O

olrt

Ok I found the answer :

------------------------------------------------------------------
Leave the AcceptRejectRule property on the
ForeignKeyConstraint object as None, the default. If you set the
property to Cascade, then submitting a pending insert on a child
row will set the RowState on both the parent and related child
rows to Unchanged and you won't be able to use a DataAdapter to
submit the pending children to the database.
------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top