超急,各位帮帮忙 :asp+sql调用存储过程分页~~无法取得记录集~~
存储过程:CREATE PROCEDURE dbo.getUser
@iPageCount int OUTPUT, --总页数
@iPage int, --当前页号
@iPageSize int, --每页记录数
@sql varchar(40) output
as
set nocount on
begin
create table t (ID int IDENTITY,
bmb_id int,
bmb_mc varchar(40))
declare @iRecordCount int
insert into t
select bmb_id,bmb_mc from dbo.[bmb]
order by bmb_id
select @iRecordCount=@@rowcount --count(*) from t
IF @iRecordCount%@iPageSize=0
SET @iPageCount=CEILING(@iRecordCount/@iPageSize)
ELSE
SET @iPageCount=CEILING(@iRecordCount/@iPageSize)+1
IF @iPage > @iPageCount
SELECT @iPage = @iPageCount
DECLARE @iStart int --start record
DECLARE @iEnd int --end record
SELECT @iStart = (@iPage - 1) * @iPageSize + 1
SELECT @iEnd = @iStart + @iPageSize -1
--if @@error <> 0 return
--set @sql=select * from t where ID> @iStart and ID <@iEnd
if @@error <> 0 return
SELECT @sql=bmb_mc
from dbo.[t]
where ID > = @iStart and ID <=@iEnd
DROP TABLE t
return @iRecordCount
return
end
GO
asp页面调用存储过程:
<!--#include file= "conn.asp " -->
<!--#include file= "adovbs.inc " -->
<% DIM pagenow,pagesize,pagecount,recordcount
DIM MyComm,MyRst
pagenow = 2
'自定义函数用于验证自然数
if isnumeric(pagenow) = false then pagenow = 1
pagesize = 5
Set MyComm = Server.CreateObject( "ADODB.Command ")
with MyComm
.ActiveConnection = conn
.CommandText = "getUser "
.CommandType = 4
.Prepared = true
.Parameters.append .CreateParameter( "RETURN ",2,4)
.Parameters.append .CreateParameter( "@iPageCount ",3,2,4)
.Parameters.append .CreateParameter( "@iPage ",3,1,4,pagenow)
.Parameters.append .CreateParameter( "@iPageSize ",3,1,4,pagesize)
.Parameters.append .CreateParameter( "@sql ",200,2,40)
Set MyRst =.Execute()
end with
response.write MyComm(0)& " <br> "
response.write MyComm(1)& " <br> "
response.write MyComm(2)& " <br> "
response.write MyComm(3)& " <br> "
response.write MyComm(4)& " <br> "
'for i=1 to