用ADOStoredProc控件执行sql的存储过程,给参数附值???急急急!!! (50分)

  • 主题发起人 主题发起人 因为我在
  • 开始时间 开始时间

因为我在

Unregistered / Unconfirmed
GUEST, unregistred user!
执行sql中的存储过程:
CREATE PROCEDURE monthdate
@classes1 varchar(20),
@classes2 varchar(20)
AS
begin
insert monthback (classes,tolltype_a,tolltype_b,tolltype_c,tolltype_d,tolltype_e,tolltype_f,tolltype_h,tolltype_i,
sumtolltype_a,sumtolltype_c,sumtolltype_h,sumtolltype_i,cartype_1,cartype_2,cartype_3,cartype_4,cartype_5,cartype_9)
(select classes,sum(tolltype_a),sum(tolltype_b),sum(tolltype_c),sum(tolltype_d),sum(tolltype_e),sum(tolltype_f),sum(tolltype_h),sum(tolltype_i)
,sum(sumtolltype_a),sum(sumtolltype_c),sum(sumtolltype_h),sum(sumtolltype_i),sum(cartype_1),sum(cartype_2),sum(cartype_3),sum(cartype_4),sum(cartype_5),sum(cartype_9)
from sfdetail
where (classes>=@classes1 and classes<=@classes2)
group by classes)
end
在delphi里用ADOStoredProc执行:
with ADOStoredProc1do
begin
Parameters.ParamByName('@classes1').Value:='2003-12-201';
Parameters.ParamByName('@classes2').Value:='2003-12-211';
ADOStoredProc1.Prepared;
ExecProc;
end;
报错:parmamter '@classes1'not found.
什么原因呢?
各位高手帮忙啊。
 
检查一下程序中存储过程名monthdate有没有指定?
 
指定了啊,在procedurename中指定啊
 
with ADOStoredProc1do
begin
Parameters.CreateParameter('@classes1'',ftString,pdOutput,20,'');
Parameters.CreateParameter('@classes2'',ftString,pdOutput,20,'');
Parameters.ParamByName('@classes1').Value:='2003-12-201';
Parameters.ParamByName('@classes2').Value:='2003-12-211';
ADOStoredProc1.Prepared;
ExecProc;
end;
 
抱歉。应该是
with ADOStoredProc1do
begin
Parameters.CreateParameter('@classes1'',ftString,pdInput,20,'');
Parameters.CreateParameter('@classes2'',ftString,pdInput,20,'');
Parameters.ParamByName('@classes1').Value:='2003-12-201';
Parameters.ParamByName('@classes2').Value:='2003-12-211';
ADOStoredProc1.Prepared;
ExecProc;
end;
 
引号是不是加错地方啦
 
哦。'@classes2''多了个引号。应该是'@classes2'
 
谢谢,有机会搓一顿
 
后退
顶部