sql - add calcfield to TQuery -
i found code create calc field tadotable in delphi somewhere ...
..... procedure tfrmmain.abstable1calcfields(dataset: tdataset); begin abstable1 fieldbyname('cost').asfloat := fieldbyname('price').asfloat * fieldbyname('quantity').asinteger; // add new field cost price * quantity !!!! end; end.
inside app create tadoquery @ rum time
try fquery.sql.clear; fquery.sql.addstrings(amemo.lines); fquery.open; ..... end;
how add more calc fields query derived first code fragment ?
i think way can creating set of persistent tfields in ide (or equivalent creation of them in code before open dataset). otherwise, when call open on dataset, iirc call bindfields , - unless dataset has set of tfields - create set of dynamic tfields last long dataset open, not include calculated fields.
by time bindfields has been called, it's late add more, have set them beforehand or not @ all.
Comments
Post a Comment