日期:2014-05-18  浏览次数:20780 次

ADO调存储过程报“对象关闭时,不允许操作”
我的存储过程:
CREATE   PROCEDURE   shop_puserid
@id   varchar(100)  
AS


declare   @pos   int  
declare   @oldPos   int  
declare   @tempstr   varchar(100)  

create   table   #temp_id  
(  
id   int  
)  


set   @pos=1  
set   @oldPos=1  
while   @pos <len(@id)  
begin  
set   @pos=charindex( ', ',@id,@oldpos)  
if   @pos> 0  
begin  
set   @tempstr=substring(@id,@oldpos,@pos-@oldpos)  
set   @oldpos=@pos+1  
end  
else  
begin  
set   @tempstr=substring(@id,@oldpos,len(@id)-@oldpos+1)  
set   @pos=len(@id)  
end  
insert   into   #temp_id  
select   @tempstr  
end  
begin
set       nocount     on  
select     z.id,c.endtime,c.startime,z.addtime   from   client   as   c   ,zhaoshang   as   z   where   c.userid=z.userid     and   z.id     in   (select   id   from   #temp_id   where   id   is   not   null)
end
drop   table   #Temp_id
GO
调用程序:
<!--#include   virtual= "/cn.asp "-->
<%
on   error   resume   next
err.clear
ids   = "28,30,31,39,38,40,41,42,43 " '
sql= "exec   shop_puserid   ' "&ids& " ' "
Set   objrs=Server.CreateObject( "ADODB.RecordSet ")
objrs.open   sql,cn,1,1

response.Write   objrs.recordcount

response.Write   err.description  
%>
但是提示错误:对象关闭时,不允许操作。
我搜索的了很多解决办法,都说是呀加上set       nocount     on  
可是加上了还是报这个错误。
我其他分页存储过程也是如此就不报错。
请高手,或者遇到过次问题解决过的朋友帮忙解释一下

------解决方案--------------------
哇,鱼也提问啊
------解决方案--------------------
在存储过程的开始as后面加一个Set Nocount On看看管用否!!
------解决方案--------------------
是不是你的ADO连接没打开
cn.open
------解决方案--------------------
這種情況一般是ADO沒有打開連接的問題,與你建立的存儲過程沒有關系
------解决方案--------------------
cn需要先打开,即:cn.Open