Page 1 of 1
Strict Update
Posted: Thu 05 Apr 2007 18:36
by ninken
I want to have strict updates enabled, but I want to trap the error message and do something. Is this possible? If not can I make a request for event OnStrictupdateError!
Thanks
Ken
Posted: Fri 06 Apr 2007 12:05
by Jackson
You can use try..except statements to catch strict update exceptions:
Code: Select all
try
MSQuery1.Edit;
MSQuery1.FieldByName('SomeFieldName').AsString := 'some value';
MSQuery1.Post;
except
on E: EDatabaseError do
//Check the MSQuery1.RowsAffected property
end;
Posted: Fri 06 Apr 2007 14:29
by Jackson
You can also set the TMSQuery.Options.StrictUpdate property to False and check the TMSQuery.RowsAffected property value in the TDataSet.AfterPost event.
The most proper way, in our opinion, is to add an unique primary key field to the table. It will guarantee that updates will affect only one record.