Re:TQuery- How to update WITHOUT using cached updates?
On Fri, 11 Dec 1998 17:36:32 +0800, "Craig Kinsman"
Quote
<cr...@systemcorp.iinet.net.au> wrote:
>Using Delphi C/S 3, Interbase 4, on NT4 (SP3).
>I have a form to edit a single record from the LOAD table using a TQuery
>with SQL:
> select * from load where customerid=:customerid
>The single row is displayed in TDBEditBoxes via a datasource linked to the
>query as usual.
>At runtime I can edit the data but the changes are not committed when I exit
>the form. When I use a TTable in similar cases changes are committed and I
>hoped TQuery would do the same. I want to use a TQuery as the result set is
>only one record.
>The TQuery has RequestLive = True.
>I'm not using cached updates as I haven't needed explicit transaction
>control.
>My question is how to update the LOAD table when the user has edited the
>data?
>Delphi Help recommends using TUpdateSQL if cached updates are used, but I
>can't find how to do it without using cached updates.
Since you are using single-row data editing controls (as opposed to the
multi-row TDBGrid), no implicit post will ever take place. You must call
the Post method for the TQuery manually. Are you doing that?
In your situation, the decision to either save or abandon the changed data
appears to be signified by the closing of this editing window/dialog. What
you might want to consider doing, then, is to create a handler for that
form's OnClose event. In that event handler, you can check the State
property of the TQuery. If it contains dsEdit or dsInsert, that means that
there are unsaved changes in the edit controls and the Post method needs to
be called. For example:
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if (Query1.State in [dsEdit, dsInsert]) then Query1.Post;
end;
No, it does not look like your scenario is one that needs cached updates.
//////////////////////////////////////////////////////////////////////////
Steve Koterski "The knowledge of the world is only to
Technical Publications be acquired in the world, and not in a
INPRISE Corporation closet."
http://www.inprise.com/delphi -- Earl of Chesterfield (1694-1773)