Page 1 of 1
TSmartyQuery
Posted: Wed 09 Apr 2008 02:07
by chads
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?
Posted: Wed 09 Apr 2008 07:49
by Plash
You should call Edit method before editing a record and Post method after editing. For example:
Code: Select all
SmartQuery.Edit;
SmartQuery.FieldByName('A').AsString := 'aa';
SmartQuery.Post;
If you do not start transaction manually, TSmartQuery component autocommits changes. So you don't need to call TOraSession.Commit method.
Posted: Wed 09 Apr 2008 13:41
by chads
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?
Posted: Thu 10 Apr 2008 07:06
by Plash
Please check that an update query is executed when you call Post method. You need to set Debug property of TSmartQuery component to True, and add OdacVcl unit to 'uses'. When Post method is called, the dialog with the text of UPDATE statement should appear.