asp 中使用存储过程一例

 有如下存储过程
Create Proc Info_Stat
@Pagesize int =15,
@pageIndex int =1
As
create Table #t(ni [int] IDENTITY (1, 1) NOT NULL ,UserName nvarchar(50) ,buy int,sell int,total int)
Insert Into #t
Select [user],
       Sum(case [type]
            When '买' then 1
            Else 0
          End) As buy,
       Sum(case [type] When '卖' then 1 Else 0 End) as sell,
       Count(Info_ID) as total
From Info
 Group by [user]
 Order by total DESC

Select * From #t Where ni>(@pageIndex -1) * @PageSize And ni<=(@pageindex * @pageSize)
Order by total DESC
Drop table #t
=============================
说明:
以上过程是用来分页显示,每个用户的供应与求购信息发布数量,采用如下方式调用时报错,错误是
 

ADODB.Recordset 错误 '800a0e78'

对象关闭时,不允许操作。

/Test/Test.asp,行 17

对应的代码是:
<%
Dim rs
Set rs=conn.Execute(" Info_Stat " & 1 & "," & 5  )
While Not rs.EOf
   Response.Write(Rs("userName") & "," & rs("buy") & "," & rs("sell") &  "," & rs("total") & "<br>")
   Rs.Movenext
Wend
%>
修改为如下则正确
<%
Dim rs
Set rs=conn.Execute(" Info_Stat " & 1 & "," & 5  )
Set rs=rs.NextRecordSet() '上面的存储过程其实反回2个记录集
While Not rs.EOf
   Response.Write(Rs("userName") & "," & rs("buy") & "," & rs("sell") &  "," & rs("total") & "<br>")
   Rs.Movenext
Wend
%>
///讨论/
对于上面的存储过程在ADO.NET 中不需要NextRecordSet也可以正常

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值