前台不能返回存储过程的 output 参数,怪怪。
存储过程是邹键的分页存储过程,其它好像都正常,可是 output参数@pageCount在前台却不能返回,总是产生异常,提示 @pageCount为空。
存储过程如下:
ALTER procedure p_splitpage
--@sql nvarchar(4000), --要执行的sql语句
@depId tinyint,
@cateId tinyint=null,
@currentpage int=1, --要显示的页码
@pagesize int=16, --每页的大小
@pagecount int=0 out --总页数
as
set nocount on
declare @p1 int
declare @sql varchar(4000)
if(@cateId is not null and @cateId!=0)
set @sql='select productId,productName,productStandard,retailPrice,normalPicture
from product where departmentId='+cast(@depId as varchar)+' and categoryId='+cast(@cateId as varchar)
else
set @sql='select productId,productName,productStandard,retailPrice,normalPicture
from product where departmentId='+cast(@depId as varchar)
exec sp_cursoropen @p1 output,@sql,@scrollopt=1,@ccopt=1,@rowcount=@pagecount output
select @pagecount=ceiling(1.0*@pagecount/@pagesize)
,@currentpage=(@currentpage-1)*@pagesize+1
select @currentpage
exec sp_cursorfetch @p1,16,@currentpage,@pagesize
exec sp_cursorclose @p1
存储过程如下:
ALTER procedure p_splitpage
--@sql nvarchar(4000), --要执行的sql语句
@depId tinyint,
@cateId tinyint=null,
@currentpage int=1, --要显示的页码
@pagesize int=16, --每页的大小
@pagecount int=0 out --总页数
as
set nocount on
declare @p1 int
declare @sql varchar(4000)
if(@cateId is not null and @cateId!=0)
set @sql='select productId,productName,productStandard,retailPrice,normalPicture
from product where departmentId='+cast(@depId as varchar)+' and categoryId='+cast(@cateId as varchar)
else
set @sql='select productId,productName,productStandard,retailPrice,normalPicture
from product where departmentId='+cast(@depId as varchar)
exec sp_cursoropen @p1 output,@sql,@scrollopt=1,@ccopt=1,@rowcount=@pagecount output
select @pagecount=ceiling(1.0*@pagecount/@pagesize)
,@currentpage=(@currentpage-1)*@pagesize+1
select @currentpage
exec sp_cursorfetch @p1,16,@currentpage,@pagesize
exec sp_cursorclose @p1
...全文
相关推荐
Sql Server 存储过程调用存储过程接收输出参数返回值
主要介绍了Sql Server 存储过程调用存储过程接收输出参数返回值,需要的朋友可以参考下
存储过程OUTPUT实例
就是一个很简单的实例。对output不熟的话可以看看
C#调用存储过程详解(带返回值、参数输入输出等)
主要介绍了C#调用存储过程的方法,结合实例形式详细分析了各种常用的存储过程调用方法,包括带返回值、参数输入输出等,需要的朋友可以参考下
存储过程的输出参数,返回值与结果集
存储过程中可以定义输出变量,返回值,执行存储过程还能获得结果集。
创建一个存储过程,以员工号为参数,返回该员工的工作年限(以参数形式返回) 存储过程.doc
存储过程练习题


