存储进程:
CREATE PROCEDURE JinChen1
@FirstDate Datetime,
@LastDate DateTime,
@ClassCode Varchar
AS
begin tran
delete from JinChenReport-----------------SELECT DISTINCT a.G_Code, a.G_Class,a.G_Name,a.G_Num,a.G_Amount,
(SELECT SUM(b.J_Num)
FROM JinKuDetail b
WHERE a.G_Code = b.J_GoodsCode and b.J_Time>=@FirstDate and b.J_Time<=@LastDate
GROUP BY b.J_GoodsCode)a1,
(select sum(b.J_Amount) from JinKuDetail b where a.G_Code=b.J_GoodsCode and b.J_Time>=@FirstDate and b.J_Time<=@LastDate GROUP BY b.J_GoodsCode) a11
FROM goods a LEFT JOIN
JinKuDetail b ON a.G_Code = b.J_GoodsCode
commit tran在DELPHI中调用:
with Adoquery1 do
begin
close;
sql.Clear;
sql.Add('exec JinChen1 :Parfirstdate,:Parlastdate');
Parameters.ParamByName('Parfirstdate').Value:=DateTimePicker1.DateTime;
Parameters.ParamByName('Parlastdate').Value:=DateTimePicker2.DateTime;
Prepared;
ExecSQL;
end;调用时:出现:‘没有执行可选特性’,请大家看看是出了什么问题!
CREATE PROCEDURE JinChen1
@FirstDate Datetime,
@LastDate DateTime,
@ClassCode Varchar
AS
begin tran
delete from JinChenReport-----------------SELECT DISTINCT a.G_Code, a.G_Class,a.G_Name,a.G_Num,a.G_Amount,
(SELECT SUM(b.J_Num)
FROM JinKuDetail b
WHERE a.G_Code = b.J_GoodsCode and b.J_Time>=@FirstDate and b.J_Time<=@LastDate
GROUP BY b.J_GoodsCode)a1,
(select sum(b.J_Amount) from JinKuDetail b where a.G_Code=b.J_GoodsCode and b.J_Time>=@FirstDate and b.J_Time<=@LastDate GROUP BY b.J_GoodsCode) a11
FROM goods a LEFT JOIN
JinKuDetail b ON a.G_Code = b.J_GoodsCode
commit tran在DELPHI中调用:
with Adoquery1 do
begin
close;
sql.Clear;
sql.Add('exec JinChen1 :Parfirstdate,:Parlastdate');
Parameters.ParamByName('Parfirstdate').Value:=DateTimePicker1.DateTime;
Parameters.ParamByName('Parlastdate').Value:=DateTimePicker2.DateTime;
Prepared;
ExecSQL;
end;调用时:出现:‘没有执行可选特性’,请大家看看是出了什么问题!
2 Parameters.ParamByName('Parfirstdate').AsString:='''' + DataTimeToStr(DateTimePicker1.DateTime) + '''';
Parameters.ParamByName('Parlastdate').AsString:='''' + DataTimeToStr(DateTimePicker2.DateTime) + '''';
还有,用存储过程还是用AdoStoredProc组件吧