I'm using a TSmartQuery component to edit the data in a table. While running/stepping through the code I can see that the field of the component is being updated. However, when I commit my changes (TOraSession.Commit) they aren't committed to the database. After the commit I can see the data has been and is still edited (via a Watch).
I'm assuming it's one of the properties of the component that I haven't set correctly but maybe not? Any suggestions?
TSmartyQuery
You should call Edit method before editing a record and Post method after editing. For example:
If you do not start transaction manually, TSmartQuery component autocommits changes. So you don't need to call TOraSession.Commit method.
Code: Select all
SmartQuery.Edit;
SmartQuery.FieldByName('A').AsString := 'aa';
SmartQuery.Post;Plash,
I'm in a transaction before I get to the code set that is editing the data. Also, I have already tried invoking the post method after the edit.
Here's an example of my code set:
SmartQuery.FieldByName('FIELD1').OnChange := nil;
SmartQuery.First;
while not SmartQuery.Eof do
begin
if (SmartQuery.FieldByName('FIELD1').AsString = '') and
(SmartQuery.FieldByName('FIELD2').AsInteger 10) then
begin
SmartQuery.Edit;
SmartQuery.FieldByName('FIELD1').AsFloat := .10;
SmartQuery.Post;
end; //end
SmartQuery.Next;
end; //while
Any other ideas?
I'm in a transaction before I get to the code set that is editing the data. Also, I have already tried invoking the post method after the edit.
Here's an example of my code set:
SmartQuery.FieldByName('FIELD1').OnChange := nil;
SmartQuery.First;
while not SmartQuery.Eof do
begin
if (SmartQuery.FieldByName('FIELD1').AsString = '') and
(SmartQuery.FieldByName('FIELD2').AsInteger 10) then
begin
SmartQuery.Edit;
SmartQuery.FieldByName('FIELD1').AsFloat := .10;
SmartQuery.Post;
end; //end
SmartQuery.Next;
end; //while
Any other ideas?