不能将数据库中的数据调出来~调出来就说至少一个参数没有被指定值。
adoq4.SQL.Add('select sum(金额) as je from jhd where 单据编码=:djbm');
adoq4.Parameters.ParamByName('djbm').Value :=edit18.Text;
adoq4.Active :=true;
if adoq4.Recordset.RecordCount >0 then
edit21.Text :=floattostr(adoq4.Fields.Fields[0].AsFloat);-----提示出错行

解决方案 »

  1.   


    adoq4.SQL.Add('select sum(je) as 金额 from jhd where 单据编码=:djbm'); 
    adoq4.Parameters.ParamByName('djbm').Value :=edit18.Text; 
    adoq4.Active :=true; 
    if adoq4.Recordset.RecordCount >0 then 
    edit21.Text :=floattostr(adoq4.FieldByname('je').asfloat);
      

  2.   

    1、一般来说,报这个错误是因为表中没有此字段引起的。
    查看你表中是否有这个字段:单据编码
    先不要肯定,看一下你的connectionString是否正确,你可以在
    adoq4.Active :=true;
    后把数据加载到表格中,就能看出来了2、再试一下
    showmessage( inttostr( adoq4.Fields.Fields.Count ))
    看是否有字段?或者,adoq4是否设置了连接字符串?3、adoq4.SQL.Add('select sum(金额) as je from jhd where 单据编码=:djbm');
    在它之前 adoq4.parameters.clear试试?4、 floattostr(adoq4.Fields.Fields[0].AsFloat)
    完全可以改成:
    adoq4.Fields.Fields[0].AsString即使为Null,它也能自己处理好
      

  3.   

    还有,adoq4.SQL.Add('select sum(金额) as je from jhd where 单据编码=:djbm'); 
    之前加一句:adoq4.SQL.clear;