Board index » delphi » Problem master/detail TADODataSet's + TClientDataSet's (+nested datasets)

Problem master/detail TADODataSet's + TClientDataSet's (+nested datasets)

Problem master/detail TADODataSet's + TClientDataSet's (+nested datasets)

TECHNOLOGIES / PLATFORMS:

Windows 2000 Advanced Server, Delphi 6.0 Enterprise, MS SQL Server 7.0,
two-tier setup dbGO / ADOExpress multi-user database application around 5 -
20 users;

DATABASE LAYOUT:

Master table with multiple orders. Detail table with multiple products sold.
The master contains a field 'MasterAmount' (float), which contains the sum
amount to be paid for all the details of that master.

((The individual amounts of the details, are too flexible for a trigger to
do the job. They inter-depend a lot. The above design choice, also meets a
lot of requirements in the application, fast reporting, direct results for
totals on screen, fast invoice creation, etc.))

WANTED:

The user must be able to edit / delete / post the details and / or the
masters on a single form, where the sum amount field in the master being the
correct sum of the amounts of the details are garantueed when all changes
are made permanent. ((The sum in the master must ALWAYS be garantueed to be
correct, no matter what power black-out or user behaviour.))

FIRST TRY (TRANSACTIONS ONLY):

I've tried starting a transaction when a user starts first editing a master
or a detail, and committing it when the user closed the form, after posting
all changes. This almost works fine, but it lets the transaction wait for
user response, and it gives some locking problems during the transaction.

SECOND TRY (DISCONNECTED ADO DATASETS):

I used disconnected ADO datasets with batchupdates. This didn't work, cause
there has to be dealt with multiple masters with a detail recordset EACH,
which ALL must be cached within one update cycle (read: transaction).

STUCK DURING LAST TRY (TCLIENTDATASET'S & NESTED DATASETS):

I read Marco Cant's remarks about TClientDataSet, and some articles on
www.delphi3000.com, newsgroups and the community site. I find really very
little information about the subject. Not even in the helpfiles of Delphi
itself. I read everywhere that TClientDataSet's are THE solution for my
problem, but I can't find a good example or explanation.

MY QUESTION TO YOU:

I want to set up a client dataset with the data of my master adodataset, and
the same for de details. I want all edits to be cached, so I can -- at the
end -- apply all the changes within a single transaction and thus garantuee
my demands (see above), or cancel all the changes.

How do I set this up? I've added a TDataSetField to the first TClientDataSet
and tried to hook it up with the second dataset, I've tried loads of ways of
hooking up the m/d realtions: Do I set it up for my TADODataSet's
(master+detail) as well as for the TClientDataSet's via the Master*
properties?  It seems to me I've got to use nested datasets (software level)
of TClientDataSet's somehow, for optimal update/delete/insert order...how?

In short: What is the best way to get what I want?  Where can I find
information or examples about that best way?

Thanks in advance & a desperate smile,

===
Mark van der Hijden
  pgp     0x4ED01C6D  (see www.pgp.com)
---
M e n d r i X - Intuitive Software Solutions
  pgp     0x66C37F9B  (see www.pgp.com)
  site    www.mendrix.nl

 

Re:Problem master/detail TADODataSet's + TClientDataSet's (+nested datasets)


"MarK - MendriX ICT" <zwoREMOVETHI...@menNOSPAMdrix.nl> wrote in message
news:3c0272d2_1@dnews...

Quote
> properties?  It seems to me I've got to use nested datasets (software

level)

The nested dataset problem is solved.

Quote
> In short: What is the best way to get what I want?  Where can I find
> information or examples about that best way?

If the TClientDataset with nested dataset option is not the way to go for
me, the question remains: What is the best way to get what I want?

Thanks people for thinking along -- if.  ;-)

A smile.

Other Threads