Is it possible to remove a record from a ClientDataset, so that we do not
see it anymore in the ClientDataset data, but without deleting it from the
database when we call ApplyUpdates ?
or, saying it another way, to have a dataset as It would be if the record
had never been retrieved
in the first place ?
thanks,
Vincent Schmid
vsc...@polylog.ch
Yes. Just use a client-side filter to prevent the record from being
displayed.
HTH,
-Craig
--
Craig Stuntz (TeamB) · Vertex Systems Corp. · Columbus, OH
We're hiring: http://www.vertexsoftware.com/careerops.htm#sd
Delphi/InterBase WebLog: http://delphi.weblogs.com
procedure TForm1.DataSetProvider1BeforeUpdateRecord(Sender: TObject;
SourceDS: TDataSet; DeltaDS: TCustomClientDataSet;
UpdateKind: TUpdateKind; var Applied: Boolean);
begin
if UpdateKind=ukdelete then
begin
// set a flag in record in database, to sign that the register
// was deleted (but I intercet and just the alter the flag)
SQLConnection1.ExecuteDirect
('Update CustomerTable set FlagDeleted=1 '+
'where CustKey='+DeltaDS.fieldbyname ('CustKey').AsString);
Applied:=true; // don't delete from database when call ApplyUpdates
end;
end;
Then, the Main Select of Query is like "SELECT * FROM CustomerTable where
FlagDeleted<>1". The user never see the old deleted records, but I see
direct in Database, and occasionally restore some records by setting the
flag.
--
Guinther de Bitencourt Pauli - guin...@unifra.br - Santa Maria - RS -
Brazil
Certified Master Delphi Programmer and Delphi 5 - Brainbench
ClubeDelphi Maganize - Author, Oficial Course Borland Midas and App.Corp.
"Vincent Schmid" <vsc...@polylog.ch> escreveu na mensagem
news:3bfbbd49_2@dnews...
Thank you all for the suggestions : it is more work than I expected, but I
will try it.
sincerely,
Vincent Schmid
>Is it possible to remove a record from a ClientDataset, so that we do not
>see it anymore in the ClientDataset data, but without deleting it from the
>database when we call ApplyUpdates ?
>or, saying it another way, to have a dataset as It would be if the record
>had never been retrieved
>in the first place ?
Take a look at LogChanges property of ClientDataSet...
--
Vladimir Ulchenko aka vavan
In TDataSetProvider.OnGetData, you can filter out the records before
they even get to the client.
eg:
procedure TdatCallout.dspRosteredResourcesGetData(Sender: TObject;
DataSet: TClientDataSet);
begin
DataSet.First;
while not DataSet.EOF do
begin
if DataSet.FieldByName('Name').AsString = 'Vincent' then
DataSet.Delete
else
DataSet.Next;
end;
end;
Hope this helps,
Cheers,
Raymond Barlow
"Vincent Schmid" <vsc...@polylog.ch> wrote in message news:<3bfbbd49_2@dnews>...