TUniTable record change (UniDAC 4.3.8)

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jota
Posts: 34
Joined: Tue 22 Nov 2011 19:21

TUniTable record change (UniDAC 4.3.8)

Post by jota » Fri 15 Feb 2013 20:51

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.

AndreyZ

Re: TUniTable record change (UniDAC 4.3.8)

Post by AndreyZ » Mon 18 Feb 2013 14:55

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.

jota
Posts: 34
Joined: Tue 22 Nov 2011 19:21

Re: TUniTable record change (UniDAC 4.3.8)

Post by jota » Tue 19 Feb 2013 12:47

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

AndreyZ

Re: TUniTable record change (UniDAC 4.3.8)

Post by AndreyZ » Wed 20 Feb 2013 13:54

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;

Post Reply