How to get for cacheddataset oldvalue from specific row?

In this forum you may discuss all issues concerning the Lazarus IDE and Freepascal (both running on Windows or Linux).

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
Soner
Junior Boarder
Junior Boarder
Posts: 27
Joined: 12.02.2017, 17:00

How to get for cacheddataset oldvalue from specific row?

Post by Soner »

I want indicate in a dbgrid edited and inserted values with red color.
1)
I created this function http://zeoslib.sourceforge.net/viewtopi ... 92#p102892.
It is working good, except the user changes sorting client side. (User clicks on column title and programm adds to zquery.Sortedfields:='somecolumn'). In this case the old values are from wrong records.
Do you know how can I get right oldvalues?

2)
Today I tried to work common way with TDataLink.ActiveRecord and downloded latest trunkversion ([r5348]).
Is there maybe a bug because when you change TDataset.ActiveRecord then you get right value but not right oldvalue?
Look at screenshot.

This is the code when you click on ActiveRecord-Button:

Code: Select all

procedure TForm1.BtnActiveRecordClick(Sender: TObject);
var aDataLink: TDataLink;
begin
  aDataLink:= TDataLink.Create;
  try
  aDataLink.DataSource:=DataSource1;
  aDataLink.ActiveRecord:=2; 
  Memo1.Lines.Add(TimeToStr(now)+'   Nr:'+ZQuery1.FieldByName('nr').AsString+'  old:'+VarToStr(ZQuery1.FieldByName('nr').OldValue)+'   Name:'+ZQuery1.FieldByName('name').AsString+'  old:'+VarToStr(ZQuery1.FieldByName('name').OldValue));
  finally
    aDataLink.Free;
  end;
end;  
You do not have the required permissions to view the files attached to this post.
Soner
Junior Boarder
Junior Boarder
Posts: 27
Joined: 12.02.2017, 17:00

Re: How to get for cacheddataset oldvalue from specific row?

Post by Soner »

Today, I tried this with SQLDB-Components from Free Pascal. It has similar error.
If you interested look here http://forum.lazarus-ide.org/index.php/ ... .msg304439
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1928
Joined: 17.01.2011, 14:17

Re: How to get for cacheddataset oldvalue from specific row?

Post by marsupilami »

Hello Soner,

do you use the ChacedUpdates functionality of Zeos to do that?
Best regards,

Jan
Soner
Junior Boarder
Junior Boarder
Posts: 27
Joined: 12.02.2017, 17:00

Re: How to get for cacheddataset oldvalue from specific row?

Post by Soner »

Yes, I am using cachedupdates.
I was happy with my solution from this topic http://zeoslib.sourceforge.net/viewtopi ... 92#p102889,
but it doesn't work with clientside sorted dataset.
If someone wants, then I can upload my modified zeoslib with an example.
Post Reply