Page 1 of 1
TUniTable record change (UniDAC 4.3.8)
Posted: Fri 15 Feb 2013 20:51
by jota
Hi
Is there a property that is changed or some event that is fired when any value in the stored rows in tunitable object is changed?
Thank in advance.
Re: TUniTable record change (UniDAC 4.3.8)
Posted: Mon 18 Feb 2013 14:55
by AndreyZ
Hello,
You can use the Modified property to determine if a record was changed. Here is a code example:
Code: Select all
UniTable1.Open;
ShowMessage(BoolToStr(UniTable1.Modified, True)); // shows False as there are no changes
UniTable1.Edit;
ShowMessage(BoolToStr(UniTable1.Modified, True)); // still shows False as there are no changes
UniTable1.FieldByName('field1').AsString := 'newvalue';
ShowMessage(BoolToStr(UniTable1.Modified, True)); // shows True as the field1 field was changed
For more information about the Modified property, please refer to the Delphi documentation.
Re: TUniTable record change (UniDAC 4.3.8)
Posted: Tue 19 Feb 2013 12:47
by jota
Hi
With this code :
Code: Select all
UniTable1.InsertRecord([KeyNum, 'Hello'])
ShowMessage(BoolToStr(UniTable1.Modified, True)); // shows False
should be so?
Is there other property that is changed or some event that is fired when insert a record?
Thanks
Re: TUniTable record change (UniDAC 4.3.8)
Posted: Wed 20 Feb 2013 13:54
by AndreyZ
It is a correct behaviour. The InsertRecord method inserts a new record and immediately posts it. That is why, the Modified property shows False.
If you want to determine that a new record was added, you can use the AfterInsert event. Here is a code example:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
begin
UniQuery1.SQL.Text := 'select * from tablename';
UniQuery1.Open;
UniQuery1.InsertRecord([values]);
end;
procedure TForm1.UniQuery1AfterInsert(DataSet: TDataSet);
begin
ShowMessage('A new record is added');
end;