读书人

delphi7调用存储过程失败。解决思路

发布时间: 2012-03-23 12:06:21 作者: rapoo

delphi7调用存储过程失败。
存储过程:
CREATE PROCEDURE Cop_SaleForecast(@BegDate Integer,
@EndDate Integer,@ItemId Varchar(18))
AS
select dtl.ItemId,sum(Dtl.Qty) as Qty,Dtl.UntId,
datepart(year,ShipDate) as date1,datepart(month,ShipDate) as date2
from Cop_Ship_Dtl Dtl,
Cop_Ship_Mst Mst
where ItemId=@ItemId and Dtl.BillId=Mst.BillID and Dtl.ShipID=Mst.ShipId
and mst.Status=1 and datepart(year,ShipDate) <=@EndDate and datepart(year,ShipDate)> =@BegDate
group by datepart(year,ShipDate),datepart(month,ShipDate) ,dtl.itemid,dtl.untid
GO


Delphi里:
ComText := 'Exec Cop_SaleForecast ';
ComText :=ComText + ' ' ' ' + edtBCltId.Text + ' ' ' , ' ;

ComText := ComText + ' ' ' '+ XcEdit2.Text + ' ' ' , ';

ComText := ComText + ' ' ' '+XcEdit1.Text+ ' ' ' ' ;
运行时:未能找到存储过程

[解决办法]
//如果存储过程在数据库中存在下面的调用方法应该是没有问题的

ComText := 'Exec Cop_SaleForecast '+strToIntDef( edtBCltId.Text,0 )+ ', '+ StrToIntDef( XcEdit2.Text,0 )+ ', ' ' '+XcEdit1.Text+ ' ' ' ';

读书人网 >.NET

热点推荐