🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.multi-tier
3 messages
3 total messages Started by Jason Cipriani Tue, 05 Feb 2008 05:03
Nested data set RecordCount as calculated field of parent.
#151
Author: Jason Cipriani
Date: Tue, 05 Feb 2008 05:03
45 lines
3122 bytes
I have a TClientDataSet with 2 fields: One field is of type DataSet and is
attached to another nested TClientDataSet, the other field is of type
Integer and is a calculated field. I want the calculatd field to display the
RecordCount of the nested TClientDataSet. Both are attached to TDBGrid
controls.

This is what I am doing now. In the following code, DSMaster is the master,
DSChild is the nested one, "Items" is the data set field, and "ItemCount" is
the calculated field. Here is my OnCalcFields handler for DSMaster:

void __fastcall TForm1::DSMasterCalcFields(TDataSet *DataSet) {

    DSMaster->FieldByName("NItems")->AsInteger =
        DSChild->RecordCount;

}

For some reason doing this cause duplicate records to appear in DSMaster's
DBGrid control. It does not add duplicate records to the database, but
rather, creates many row in the DBGrid that all reference the same record
(i.e. edit one and the change shows up in all the copies). The duplication
appears somewhat random but is somehow related to how I use the vertical
scroll bar in the DBGrid control.

Questions:

1) How do I do what I'm trying to do -- that is, display the number of
records in a nested data set in a calculated field of the master data set?

2) How do I access the TClientDataSet of a TField that is a data set? There
is AsInteger, AsString, etc., but no AsDataSet? Without being able to do
this I can not calculate fields in OnCalcFields using only the TDataSet*
passed to the function, I must use some variables from outside the function
as well (e.g. using DSChild in the above example).

3) Is this not the right newsgroup for questions about TClientDataSets? The
borland.public.cppbuilder.database.desktop newsgroup is all but dead, and
none of the other borland.public.cppbuilder.database.* groups looked
appropriate. This -is- a VCL component, and as a matter of fact it's one of
my favorites, but nobody seems to know much about it. From what I've read
TClientDataSet was only recently moved from Enterprise to Professional
edition so maybe it's a mystery to everybody, still.

Thanks,
Jason
Re: Nested data set RecordCount as calculated field of parent.
#152
Author: vavan
Date: Tue, 05 Feb 2008 06:57
9 lines
1232 bytes
On Tue, 5 Feb 2008 00:03:54 -0500, "Jason Cipriani"
<jason.cipriani@nospam-gmail.com> wrote:

>3) Is this not the right newsgroup for questions about TClientDataSets? The

ask in .datasnap and .delphi.database.multi-tier

-- 
Vladimir Ulchenko aka vavan
Re: Nested data set RecordCount as calculated field of parent.
#153
Author: Jason Cipriani
Date: Tue, 05 Feb 2008 08:08
14 lines
1478 bytes
All right, thanks.

"vavan" <VavanRemove@ThisSantel.ru> wrote in message 
news:v32gq3dlukgstgdpkpncq17ud2h41lpukt@4ax.com...
> On Tue, 5 Feb 2008 00:03:54 -0500, "Jason Cipriani"
> <jason.cipriani@nospam-gmail.com> wrote:
>
>>3) Is this not the right newsgroup for questions about TClientDataSets? 
>>The
>
> ask in .datasnap and .delphi.database.multi-tier
>
> -- 
> Vladimir Ulchenko aka vavan 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads