|
楼主 |
发表于 2007-8-2 16:12:29
|
显示全部楼层
用你的代码是可以的..
不知道什么原因.
我把代码贴出来.你帮我看看。
Procedure TWBRB.SumByWbxm;//(Adate:String;BDate:String;Cdw:String);//(A:String;B:String;C:String);
var lQuery:TQuery;
lQuery_Str:String;
A:String;B:String;C:String;DW:String;
begin
a:=DataSetWBC.FieldByName ('bc').AsString ;
b:=DataSetWBC.FieldByName ('xm').AsString ;
c:=DataSetWBC.FieldByName ('s_z').AsString ;
dw:=DataSetWBz.FieldByName ('TBDW').AsString ;
lQuery:=TQuery.Create (nil);
try
lQuery.ConnectionString :=StrConn;
lQuery_Str:='select bc,xm,s_z,lj=sum(je) from wbmxb '
+'where ZBGUID IN (select GUID from wbrbzb where tbdw= '''+dw+''' )'+' and '+
' tbrq<= CONVERT(varchar(10),getDate(),120) '+' and '+
'bc= '''+a+''' and xm= '''+b+''+'''and s_z= '''+c+''''
+' group by bc,xm,s_z ';
lQuery.CommandText :=lQuery_Str;
lQuery.open;
// DataSetWBC.Edit;
DataSetWBC.FieldByName ('jeLJ').AsFloat :=lQuery.Fields[3].AsFloat ;
//DataSetWBC.Post;
finally
lQuery.free;
end;
end; |
|