有如下存储过程
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也可以正常