想在日期里找出一段时间的数据:
数据为:  TDate       price    number
         20060912     12          2
         20060913      9          1
         20060914      8          4
         20060915     45          1 
         20060916      9          6
         20060917     78          1
         20060918     45          7       Query1.Close;
       Query1.SQL.Clear;
       Query1.SQL.Add('select * from bill.db where 1=1 ');
       Query1.SQL.Add(' and  TDate>=bill1  and  TDate <=bill2 ');
       Query1.open;
       但是DBGrid3没有任何显示
还有我想在上面的基础上再求个和
select sum(price*number)然后在edit4.Text里面显示出来呵呵   是不是很无奈呀
我才接触Delphi不久
如有那个高手愿收我为徒那是更好不过了
不过先说明:我什么都不会,但我很有激情!!!望高手们多多指教
在线等待
       

解决方案 »

  1.   

    应该是这一段参数赋值的问题and  TDate>=bill1  and  TDate <=bill2还有,就是你的tdate是什么类型,字符类型还是日期时间类型?
      

  2.   

    Query1.Close;
           Query1.SQL.Clear;
           Query1.SQL.Add('select select sum(price*number) as spm from bill.db where  ');
           Query1.SQL.Add('  TDate>=:bill1  and  TDate <=:bill2 ');
           Query1.parambyname('bill1').value := edit1.text;
           Query1.parambyname('bill2').value := edit2.text;
           Query1.open;edit4.Text := Query1.parambyname('spm').asstring;
      

  3.   

    谢谢楼上的大师们我慢慢试下
    我那个TDate已转变为字符型了
    我的QQ是53367688
    那位大师愿意收徒
    就请加我吧