请教各位,我刚刚开始学习delphi,作了一个产品数据库,用了个tquery在sql属性中输入了 sum (数量)from Product where Productname = motor 又用了个tedit想把结果显示在里面,用了open,了但是怎么把结果输出到tedit里呢? 不知道tedit.text应该要怎么取法 希望大家能帮忙看看,谢谢了
with TQuery.Create(nil) do
try
DataBaseName := '你设的DataBase的名字';
Close;
SQL.Clear;
SQL.ADD('Select sum(数量) as total where Productname =''motor''');
Open;
if not eof then edit.text := FieldByName('total').AsString
else ShowMessage('没有记录!');
finally
Free;
end;