用asp调用存储过程的问题,弄了两天了
单位写的过程很奇怪,有时候可以调用,有时候报错对象关闭,无法操作
调用方法:
1,rs.Open "Exec new_1 '12345'",conn2,1,3
2,set rs=Server.CreateObject("ADODB.Recordset")
set cmd=Server.CreateObject("ADODB.Command")
set cmd.ActiveConnection=conn2
with cmd
.CommandText ="px_zcfzb"
.CommandType = 4
.parameters.Refresh
.parameters("@nd")=2002
.parameters("@code")=600839
end with
set rs=cmd.Execute()
3,SQLString="new_1 '12345'"
set rs=connect.Execute(SQLString)
一操作rs.eof 或者rs.movenext就出错
附上某个过程,个人感觉好像和过程没有什么关系,因为在库里过程是能够执行的
declare @sql varchar(3000),@rq1 varchar(10),@rq2 varchar(10),@rq3 varchar(10),@rq4 varchar(10)
if month(getdate()) between '01' and '03'
begin
if (select max(len(q4)) from zcfzb where code=@code and nd=year(getdate())-1 and y=1) is null
begin
select @rq1=convert(char(4),year(getdate())-2)+'-12-31',@rq2=convert(char(4),year(getdate())-1)+'-03-31',@rq3=convert(char(4),year(getdate())-1)+'-06-30',@rq4=convert(char(4),year(getdate())-1)+'-09-30'
SET @SQL='select (select top 1 mc from bmqk where bmlb=''zcfz'' and bm=xm) as mc,(select a.q4 from zcfzb a where a.nd=year(getdate())-2 and a.y=1 and a.code='+@code+' and a.xm=zcfzb.xm) as '''+@rq1+''',q1 as '''+@rq2+''',q2 as '''+@rq3+''',q3'''+@rq4+''' from zcfzb where nd=year(getdate())-1 and y=1 and code= '+@code+''
end
else
begin
select @rq1=convert(char(4),year(getdate())-1)+'-03-31',@rq2=convert(char(4),year(getdate())-1)+'-06-30',@rq3=convert(char(4),year(getdate())-1)+'-09-30',@rq4=convert(char(4),year(getdate())-1)+'-12-31'
SET @SQL='select (select top 1 mc from bmqk where bmlb=''zcfz'' and bm=xm) as mc,q1 as '''+@rq1+''',q2 as '''+@rq2+''',q3 as '''+@rq3+''',q4 as '''+@rq4+''' from zcfzb where nd=year(getdate())-1 and y=1 and code= '+@code+''
end
exec (@sql)
end
GO