此语句在BDE中用时是正常的
query1.Close;
query1.sql.Clear;
query1.sql.add('select itemtype.descriptionb,itemcode.descriptionb,original,left(sum(quantity),4),left(original*sum(quantity),10) from posiage join itemcode on itemcode.itemcode=posiage.itemcode join itemtype on itemtype.itemtype=itemcode.itemtype where'+'');
query1.sql.add('posttime between
f) and
e) and posiage.creordeb=0 and itemtype.descriptionb=:s group by itemcode.descriptionb,original,itemtype.descriptionb order by itemtype.descriptionb');
query1.ParamByName('f').asstring:=datetostr(dt1.date);
query1.ParamByName('e').asstring:=datetostr(dt2.date);
query1.ParamByName('s').asstring:=(cbx.text);
query1.prepare;
query1.open;
结果一切正常。
在ADO 中我用
ADODATASET1.Close;
adodataset1.CommandText:='';
adodataset1.commandtext:='select itemtype.descriptionb,itemcode.descriptionb,original,left(sum(quantity),4),left(original*sum(quantity),10) from posiage join itemcode on itemcode.itemcode=posiage.itemcode join itemtype on itemtype.itemtype=itemcode.itemtype'+'where'+''
+ 'posttime between
f) and
e) and posiage.creordeb=0 group by itemcode.descriptionb,original,itemtype.descriptionb order by itemtype.descriptionb';
adodataset1.commandtype:=cmdtext;
adodataset1.Parameters.parambyname('f').value:=datetostr(dt1.date);
adodataset1.Parameters.parambyname('e').value:=datetostr(dt2.date);
adodataset1.Prepared;
adodataset1.open;
编译不出错可用时就报错,用ADODQUERY也如此,