with adoquerytemp1 do
begin
Active:=false;
SQL.Clear;
SQL.Add('SELECT clb.sbid,sbb.sbname,sum(clb.rcl)');
SQL.Add(' FROM clb INNER JOIN sbb ON clb.SBID=sbb.SBID');
SQL.Add(' WHERE trim(str(year(clb.tdate)))=:ptdate');
Parameters.ParamByName('ptdate').Value :=trim(edit1.Text);
SQL.Add(' and trim(str(month(clb.tdate)))=:pm');
Parameters.ParamByName('pm').Value:=trim(edit2.Text);
SQL.Add(' GROUP BY clb.sbid,sbb.sbname');
Prepared:=true;
ExecSQL;
Active:=true;
end;
改为
with adoquerytemp1 do
begin
close;
SQL.Clear;
SQL.Add('SELECT clb.sbid,sbb.sbname,sum(clb.rcl)');
SQL.Add(' FROM clb INNER JOIN sbb ON clb.SBID=sbb.SBID');
SQL.Add(' WHERE trim(str(year(clb.tdate)))=:ptdate');
Parameters.ParamByName('ptdate').Value :=trim(edit1.Text);
SQL.Add(' and trim(str(month(clb.tdate)))=:pm');
Parameters.ParamByName('pm').Value:=trim(edit2.Text);
SQL.Add(' GROUP BY clb.sbid,sbb.sbname');
Prepared:=true;
ExecSQL;
exsql;
end;
begin
Active:=false;
SQL.Clear;
SQL.Add('SELECT clb.sbid,sbb.sbname,sum(clb.rcl)');
SQL.Add(' FROM clb INNER JOIN sbb ON clb.SBID=sbb.SBID');
SQL.Add(' WHERE trim(str(year(clb.tdate)))=:ptdate');
Parameters.ParamByName('ptdate').Value :=trim(edit1.Text);
SQL.Add(' and trim(str(month(clb.tdate)))=:pm');
Parameters.ParamByName('pm').Value:=trim(edit2.Text);
SQL.Add(' GROUP BY clb.sbid,sbb.sbname');
Prepared:=true;
ExecSQL;
Active:=true;
end;
改为
with adoquerytemp1 do
begin
close;
SQL.Clear;
SQL.Add('SELECT clb.sbid,sbb.sbname,sum(clb.rcl)');
SQL.Add(' FROM clb INNER JOIN sbb ON clb.SBID=sbb.SBID');
SQL.Add(' WHERE trim(str(year(clb.tdate)))=:ptdate');
Parameters.ParamByName('ptdate').Value :=trim(edit1.Text);
SQL.Add(' and trim(str(month(clb.tdate)))=:pm');
Parameters.ParamByName('pm').Value:=trim(edit2.Text);
SQL.Add(' GROUP BY clb.sbid,sbb.sbname');
Prepared:=true;
ExecSQL;
exsql;
end;
这个问题我也碰到,可能需要下在ADO,Dephi补丁.
执行数据更新时用的(Insert,Update...)换为Open或者
Active=True即可。