Board index » delphi » Re: LogChanges and ChangeCount properties of TClientDataset component

Re: LogChanges and ChangeCount properties of TClientDataset component


2006-11-28 11:45:35 PM
delphi193
Enquiring Mind writes:
Quote
Can anyone clarify the following for me? When I inspect in the
de{*word*81} the value of the property ChangeCount of a ClientDataset
after making a change to it, I unexpectedly find that the value is
zero.
Have you posted your change? ChangeCount doesn't go up until you Post.
--
Craig Stuntz [TeamB] ?Vertex Systems Corp. ?Columbus, OH
Delphi/InterBase Weblog : blogs.teamb.com/craigstuntz
Want to help make Delphi and InterBase better? Use QC!
qc.borland.com -- Vote for important issues
 
 

Re: LogChanges and ChangeCount properties of TClientDataset component

Hi,
Can anyone clarify the following for me? When I inspect in the de{*word*81} the
value of the property ChangeCount of a ClientDataset after making a change
to it, I unexpectedly find that the value is zero. The Clientdataset in
question is linked to a DatasetProvider, which in turn is linked to a
TSQLDataset. I then tried to inspect the value of the LogChanges property
to check that it was set to True, but found that the underlying fumction
GetLogChanges had been eliminated by the linker.
So what exactly does the value of ChangeCount represent? Is the total number
of changes since the TClientDatset was created/opened, or the total number
minus 1? The Online help gives an example that would seem to suggest that in
order to check whether the client dataset has changed one may use the
statement
if Clientdataset1.ChangeCount>0 then Clientdataset1.ApplyUpdates(0);
Thanks in advance for any advice on the matter.
Regards,
Enquiring Mind
 

Re: LogChanges and ChangeCount properties of TClientDataset component

"Craig Stuntz [TeamB]" <XXXX@XXXXX.COM [a.k.a. acm.org]>wrote
in message news:XXXX@XXXXX.COM...
Quote
Enquiring Mind writes:

>Can anyone clarify the following for me? When I inspect in the
>de{*word*81} the value of the property ChangeCount of a ClientDataset
>after making a change to it, I unexpectedly find that the value is
>zero.

Have you posted your change? ChangeCount doesn't go up until you Post.

Thanks for the advice. I take it that ChangeCount is incremented only if
changes are found in the Post operation, which I presume compares old values
and new values of each field in the current record before updating the
fields. Is that correct?
Enquiring Mind
 

Re: LogChanges and ChangeCount properties of TClientDataset component

Enquiring Mind writes:
Quote
Thanks for the advice. I take it that ChangeCount is incremented
only if changes are found in the Post operation, which I presume
compares old values and new values of each field in the current
record before updating the fields. Is that correct?
No, not exactly. New and old values aren't compared. Here's what
generally happens:
1) You assign a field value.
2) Assigning this value sets the modified flag of the dataset. Just
like SQL, you can assign a field to its current value and it will still
be considered an assignment.
3) You call DataSet.CheckBrowseMode. CheckBrowseMode looks at the
modified flag and posts if it is set, cancels if it doesn't.
4) Actually posting the record adds the record to the CDS's delta
packet, which in turn increments ChangeCount.
--
Craig Stuntz [TeamB] ?Vertex Systems Corp. ?Columbus, OH
Delphi/InterBase Weblog : blogs.teamb.com/craigstuntz
Want to help make Delphi and InterBase better? Use QC!
qc.borland.com -- Vote for important issues