Hi All
Anyone tell me how to use a TQuery with an
update component to insert a new record.
I have managed to do it so far in the following
way :
with dmGlobal.qryWindLog
do
begin
Close;SQL.Clear;SQL.Add('select * from WINDDATA.DB');SQL.Add('where RTU_ID = 16000');Open;Insert;FieldValues['RTU_ID'] := Self.ID;FieldValues['LogTime'] := Self.LastPoll;FieldValues['Direction'] := Self.WindDir;FieldValues['Average'] := Self.WindSpdAv;FieldValues['Peak'] := Self.WindSpdGust;ApplyUpdates;
end;
OK - But I don't think that I should
have to execute the TQuery first - If I set the SQL strings to empty then I
throw an exception so whats the recommended way ?? I put the RTU_ID = 16000 so
no records would be returned but its a kluge ...
I use this same
setup (basically but no setting field for delete) to edit and delete records but
use <edit> or <delete> instead of <insert>.
This seems to
make sense if modifying an existing record but not for insert or delete. By the
by - I found that if I do an edit on a non existent record then a new record is
inserted - is this right ??
Paul Lowman
software/hardware developer
Lowman Consulting
software/hardware developer
Lowman Consulting