Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The Oder Of Posting Master/Detail DataSets

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
"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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top