PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Relation Grand-parent/Grand-child in a typed DataSet

Reply

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

 
Thread Tools Rate Thread
Old 06-04-2006, 09:56 PM   #1
olrt
Guest
 
Posts: n/a
Default Relation Grand-parent/Grand-child in a typed DataSet


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();

------------------------------------------------------

  Reply With Quote
Old 08-04-2006, 05:10 PM   #2
olrt
Guest
 
Posts: n/a
Default Re: Relation Grand-parent/Grand-child in a typed DataSet

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 ?

  Reply With Quote
Old 10-04-2006, 01:31 PM   #3
olrt
Guest
 
Posts: n/a
Default Re: Relation Grand-parent/Grand-child in a typed DataSet

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.
------------------------------------------------------------------

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off