我要求和,要满足两个条件,一个当前EDIT4.TEXT的内容,一个是数据表CHGS字段为负数,下面是我的代码会出错(就是CHGS负数的出错)请各位指点一下
with f_data.bill do
begin
close;
sql.Clear;
sql.Add('select sum(chgs) as aa from mybill where code=:code ');
sql.Add('and chgs<0');
Parameters.ParamByName('code').Value:=edit4.Text;
open;
end;
label14.Caption:=floattostr(-f_data.bill.FieldByName('aa').Value)+'元';
with f_data.bill do
begin
close;
sql.Clear;
sql.Add('select sum(chgs) as aa from mybill where code=:code ');
sql.Add('and chgs<0');
Parameters.ParamByName('code').Value:=edit4.Text;
open;
end;
label14.Caption:=floattostr(-f_data.bill.FieldByName('aa').Value)+'元';
begin
close;
sql.Clear;
sql.Add('select sum(chgs) as aa from mybill where code = ''' + edit4.Text +''' ');
sql.Add('and chgs <0');
open;
end; 这样试试