Problem with using the property ClientDataSet.ChangeCount

Problem with using the property ClientDataSet.ChangeCount

Post by Pete » Thu, 03 Mar 2005 02:13:23



Hi,

I wrote the following code to keep track of whether or not
ClientDataSet1 is still having any records not updated into
server.

After applying a successful updates, ClientDataSet1.ChangeCount
should become 0. But why does ClientDataSet1AfterApplyUpdates
method print 'ChangeCount>0'. If I click btnShowDelta, it is
right to print 'ChangeCount<=0'. So how come we get two
different outputs for the same ChangeCount property?

---------------------------
procedure TForm1.btnShowDeltaClick(Sender: TObject);
begin
if (ClientDataSet1.ChangeCount > 0) then
showmessage('ChangeCount > 0')
else
showmessage('ChangeCount <= 0');
end;

procedure TForm1.btnUpdateClick(Sender: TObject);
begin
ClientDataSet1.ApplyUpdates(-1);
end;

procedure TForm1.ClientDataSet1AfterApplyUpdates(Sender: TObject; var OwnerData: OleVariant);
begin
btnShowDelta.Click;
end;
---------------------------

Thanks in advance,
Peter
 
 
 

Problem with using the property ClientDataSet.ChangeCount

Post by Kostas Ter » Thu, 03 Mar 2005 02:57:54


If you check at ApplyUpdates source code in DBClient.pas then you will
notice that DoAfterApplyUpdates is called (and the event triggered)
before the call to Reconcile. Reconcile is responsible for clearing the
delta (either by triggering the OnReconcile event for errors or merging
changes brought by server if poPropogateChanges is True)