Hello,
for logging purposes, I would like to get a list of the changed fields in a dataset, as the update is sent to the DB server.
The UnisSQLMonitor component, can deliver text which contains the info, but I was wondering if there is a more straightforward way to do it.
Best regards Lars Geisler
Can I get changed fields from a dataset
-
LarsGeisler
- Posts: 10
- Joined: Fri 25 Jun 2010 09:00
- Location: Denmark
-
AndreyZ
Hello,
To get modified fields, you can use the following code in the BeforeUpdateExecute event handler:
To get modified fields, you can use the following code in the BeforeUpdateExecute event handler:
Code: Select all
procedure TMainForm.UniQueryBeforeUpdateExecute(Sender: TDataSet;
StatementTypes: TStatementTypes; Params: TDAParams);
var
str: TStringList;
i: integer;
begin
str := TStringList.Create;
try
for i := 0 to Sender.FieldCount - 1 do
if Sender.Fields[i].NewValue Sender.Fields[i].OldValue then
str.Add(Sender.Fields[i].FieldName);
ShowMessage('Modified fields: ' + #13#10 + str.Text);
finally
str.Free;
end;
end;-
LarsGeisler
- Posts: 10
- Joined: Fri 25 Jun 2010 09:00
- Location: Denmark
Great - just what i want!!
Thank you 