Parent Child Relationships in the DataSet - SQL 2000

M

Mr Newbie

Sorry to bother you guys but I have another questions related to DataSets.

I'm almost there now, so I dont expect to bug you much more ( Hopefully ).

I have Master / Details tables with cascading relationships between them.

When I Update the master using the DataAdapter we get a new ID for the new
master row and all the child row foreign keys are updated to the newly
aquired ID.

However, from an article below from bill vaughn, he suggests ( Unless I
have misunderstood ) that the child rows would be automatically inserted
into the SQL Database after the master row has been created and they get
their foreign keys.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/manidcrisis.asp

I am at a bit of a loss as to how this could be done with one insert command
( Not demonstrated in the article ). If you configure a second DataAdapter
for the Details table, this does not insert the rows after the initial
Master row creation.

I would appreciate some help as to where I may be going wrong ?

Thanks In Advance !
 
B

Bart Mermuys

Hi,

Mr Newbie said:
Sorry to bother you guys but I have another questions related to DataSets.

I'm almost there now, so I dont expect to bug you much more ( Hopefully ).

I have Master / Details tables with cascading relationships between them.

When I Update the master using the DataAdapter we get a new ID for the new
master row and all the child row foreign keys are updated to the newly
aquired ID.

However, from an article below from bill vaughn, he suggests ( Unless I
have misunderstood ) that the child rows would be automatically inserted
into the SQL Database after the master row has been created and they get
their foreign keys.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/manidcrisis.asp

<quote>When you execute the Update method, ADO.NET executes the INSERT for
the parent row first and then all associated child rows. </quote>

I think he just meant that first the parents rows are inserted then the
related child rows but not necessarily with one DataAdapter.Update. Just
after that he starts explaining how to do the actual update using two
DataAdapters (parent/child) in three steps (to avoid concurrency issues) and
that's what you should do.

See above/below "Listing 1. Correct Update method sequencing" in the
article.

HTH,
Greetings
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top