Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / April 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
olrt - 06 Apr 2006 21:56 GMT
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();

------------------------------------------------------
olrt - 08 Apr 2006 17:10 GMT
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 ?
olrt - 10 Apr 2006 13:31 GMT
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.
------------------------------------------------------------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.