dataset editing/inserting & filter

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 296
Joined: Thu 12 Oct 2006 09:34

dataset editing/inserting & filter

Post by Ludek » Wed 01 Jun 2016 12:54

I'm having following problem: i have a filtered tmsquery (filter = 'a = 5'), do an append, set a to 6 and post. the record immediately after post disappers. Even in afterpost is an other record active. This makes big trouble, if the code in afterpost event somehow analyzes the currently posted data (as it analyzes an other record).

Is there some nice way to "correct" this? Or, at least, to disallow such post, if the new record won't meet the filter criteria? I tried anything like subclassing tmsquery and writing code like

Code: Select all

procedure TMyMSQuery.InternalPost;
    if (data as TMemData).OmitRecord((data as TMemData).GetCurrentItem) then
      raise Exception.Create('Saved record would be filtered out. Save aborted.');
byt currentitem is nil dataset in dsinsert state... also OmitRecord(activebuffer) did not work... Some other way?
Thanks, Ludek.

Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: dataset editing/inserting & filter

Post by AlexP » Tue 07 Jun 2016 07:31


This is correct behavior, since AfterPost occurs after the record is "written" into the DataSet, and all the conditions, that are applied to the DataSet, are applied to the record as well. If you want to analyze the inserted data, you should use the BeforePost event.

Post Reply