想点击buttom1然后edit1显示 统计出表sale中的total 
在查询分析器中我使用了compute sum(toeal)可以显示出来!但是不知怎样用edit1显示!
以下是buttom1代码:
procedure Tquerysale.Button1Click(Sender: TObject);
begin
dm.ADSsale.Close;
dm.ADSsale.CommandText:='select sale.*,goods.g_name from sale, goods where Sale.g_id=goods.g_id and  S_date between '+#39+datetostr(datetimepicker1.Date)+#39+' and '+#39+datetostr(datetimepicker2.Date)+#39+'compute sum(total)';
dm.ADSsale.Open;
if dm.ADSsale.RecordCount<0 then
   application.MessageBox('没有销售记录,请确认日期!','商品销售查询',mb_ok+mb_iconerror+mb_applmodal);
end;
各位大大教教我应该怎样加啊?

解决方案 »

  1.   

    edit1.text := dm.ADSsale.FieldByName('这里填写合计的字段名').AsString;
      

  2.   

    ADSsale后面没有FieldByName啊!我的ADSsale是TADODataSet
      

  3.   

    adodataset1.FieldByName()
    肯定有的
      

  4.   

    添加了这段代码运行时点击buttom1弹出错误框!
    调试器检测到错误
    工程project1.exe检测到错误EAccessViolation,错误信息:‘access violation at address 004adddb in module'project1.exe'.read of address 00000000’.进程终止。使用单步或运行举行运行。
      

  5.   

    出现这种错误一般是需要读取的资源被提前释放
    你看看你这句
    edit1.text := dm.ADSsale.FieldByName('这里填写合计的字段名').AsString;
    写的位置?
      

  6.   

    compute sum(qty) 是一个聚合函数.在sql中你应该 select sum(qty) as c from .....这样单独取一下