×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

The Oder Of Posting Master/Detail DataSets

The Oder Of Posting Master/Detail DataSets

The Oder Of Posting Master/Detail DataSets

(OP)
"Applying updates for master/detail tables"---
When you apply updates for master/detail tables, the order in which you list datasets to update is significant. Generally you should always update master tables before detail tables, except when handling deleted
records.
---End of quote---

The technique introduced in help is exactly what I need. However, its real behavior works contrarily. This unexpected behavior makes me fail to continue my job because I need to verify the values of master record before updating detail records.

Question (A): C++Builder/Delphi first triggers the detail dataset in master-detail relationship whenever DataSet->Post() is executed. Is this behavior reasonable or a bug?

Question (B): How do I post master dataset before detail dataset without adopting the CachedUpdate technique?

Thanks in advance!

CN
------------
Below is what I have tested:

(1) Drop a pair of TTable, TDataSource, and TDBGrid components.
(2) Use DBDEMOS as the Database, and assign orders.db to Table1, and
items.db to Table2. Set both tables to Active.
(3) Use field OrderNo as the link between Table1 and Table2 to make
Table1 as master dataset and Table2 as detail dataset.
(4) Drop a TButton component.
(5) Write codes:

TForm1::Table1BeforePost(TDataSet *DataSet);
{ ShowMessage("Master"); }

TForm1::Table2BeforePost(TDataSet *DataSet);
{ ShowMessage("Detail"); }

TForm1::Button1Click(TObject *Sender);
{ Table1->Post(); }

(6) Run this project and make changes to values of BOTH Table1 and Table2.
(7) Click on Button1 and we will see "Detail dataset." displayed first! This is NOT what I want.
(8) Reset program. Remove DataSource1 from property MasterSource of Table2.
(9) Run this project again and make changes to values of BOTH Table1 and Table2. We see only "Master dataset." is displayed, which is correct.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close