Server.CreateObject("ADODB.Command")调用存储过程返回来的记录集数量为-1??

亚细亚 2015-04-01 11:49:21
通过MyComm=Server.CreateObject("ADODB.Command")创建的对象来调用存储过程,结果返回的记录集的数为-1(second_t 表实际有多个记录),这是怎么回事?
asp代码如下:

<%
Set MyComm = Server.CreateObject("ADODB.Command")
dCmdSPStoredProc = 4
adParamReturnValue = 4
adParaminput = 1
adParamOutput = 2
adInteger = 3
adVarChar = 200
adVarWChar = 202
with MyComm
.ActiveConnection = Conn
.CommandText = "power_show_p"
.CommandType = 4
.Prepared = true
end with
set rs=MyComm.Execute
response.Write(rs.recordcount)
%>

存储过程如下:

create procedure power_show_p
as
SET NOCOUNT ON
begin
select * from second_t
end
...全文
470 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zlstyle 2017-03-24
  • 打赏
  • 举报
回复
参数不对的原因,使用re.open str,conn,1,1,打开记录集,recordsetcount=-1 使用re.open str,conn,1,3,打开记录集,recordsetcount=实际记录数
hookee 2015-04-02
  • 打赏
  • 举报
回复
.... Set rs = .Execute() 改成: Set rs = CreateObject("ADODB.RecordSet") rs.CursorLocation = 3 rs.Open MyComm, Conn, 1, 3 ...
wangsdong1 2015-04-01
  • 打赏
  • 举报
回复
Set MyComm = Server.CreateObject("ADODB.Command") dCmdSPStoredProc = 4 adParamReturnValue = 4 adParaminput = 1 adParamOutput = 2 adInteger = 3 adVarChar = 200 adVarWChar = 202 with MyComm .ActiveConnection = Conn .CommandText = "power_show_p" .CommandType = 4 .Prepared = true Set rs = .Execute end with if rs.state = 0 then '未取到数据,rs关闭 recordcount = -1 else rs.close '注意:若要取得参数值,需先关闭记录集对象 recordcount = MyComm(0) pagecount = CInt(MyComm(1)) if cint(pagenow)>=cint(pagecount) then pagenow=pagecount end if
亚细亚 2015-04-01
  • 打赏
  • 举报
回复
引用 4 楼 wangsdong1 的回复:
recordcount = MyComm(0) 在这下面输出一下recordcount看看有没有值
没有
wangsdong1 2015-04-01
  • 打赏
  • 举报
回复
recordcount = MyComm(0) 在这下面输出一下recordcount看看有没有值
亚细亚 2015-04-01
  • 打赏
  • 举报
回复

    Set MyComm = Server.CreateObject("ADODB.Command")
                dCmdSPStoredProc = 4              
                adParamReturnValue = 4
                adParaminput = 1
                adParamOutput = 2
                adInteger = 3
                adVarChar = 200
                adVarWChar = 202
    with MyComm
       .ActiveConnection = Conn                        
       .CommandText      = "power_show_p"                  
       .CommandType      = 4                             
       .Prepared         = true   
      set rs=.Execute                     
    end with
   
     response.Write(rs.recordcount)
修改之后,还是不行,哪位能够解释一下?谢谢!
亚细亚 2015-04-01
  • 打赏
  • 举报
回复
按照你的做法,虽然不是-1,但是出不了数;

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧