如何书写这句存储过程?aspnetpager中的.
ALTER procedure GsjyShowDGProcessor
(@where varchar(100),
@pagesize int,
@pageindex int,
@docount bit)
as
set nocount on
declare @RecordCount int
select @RecordCount=count (id) from news
if(@docount=1)
select @RecordCount
else
begin
if(@pageindex=1)
exec('select top '+@pagesize+'* from news'+@where+' order by indextime desc')
else
begin
declare @PageUpperBound int
declare @endrecords int
set @PageUpperBound=@pageindex*@pagesize
if(@PageUpperBound-@pagesize)>=@RecordCount
select ''
else if(@RecordCount-(@PageUpperBound-@pagesize)<=@pagesize)
begin
set @endrecords=@RecordCount-(@PageUpperBound-@pagesize)
exec('select * from (select top '+@endrecords+' * from news'+@where+' order by indextime)A order by indextime desc')
end
else
exec('select * from (select top '+@pagesize+'* from (select top '+@PageUpperBound+' * from news'+@where+' order by indextime desc)A order by indextime)B order by indextime desc')
end
end
set nocount off
我的@where参数是如"where a='1'and b='2' and c='3' ....."程序中生成的动态语句.
如何改写select @RecordCount=count (id) from news
使RecordCount 的值是条件中的记录总数,而不是所有的记录数.
这个@where参数该如何添上?
谢谢.
(@where varchar(100),
@pagesize int,
@pageindex int,
@docount bit)
as
set nocount on
declare @RecordCount int
select @RecordCount=count (id) from news
if(@docount=1)
select @RecordCount
else
begin
if(@pageindex=1)
exec('select top '+@pagesize+'* from news'+@where+' order by indextime desc')
else
begin
declare @PageUpperBound int
declare @endrecords int
set @PageUpperBound=@pageindex*@pagesize
if(@PageUpperBound-@pagesize)>=@RecordCount
select ''
else if(@RecordCount-(@PageUpperBound-@pagesize)<=@pagesize)
begin
set @endrecords=@RecordCount-(@PageUpperBound-@pagesize)
exec('select * from (select top '+@endrecords+' * from news'+@where+' order by indextime)A order by indextime desc')
end
else
exec('select * from (select top '+@pagesize+'* from (select top '+@PageUpperBound+' * from news'+@where+' order by indextime desc)A order by indextime)B order by indextime desc')
end
end
set nocount off
我的@where参数是如"where a='1'and b='2' and c='3' ....."程序中生成的动态语句.
如何改写select @RecordCount=count (id) from news
使RecordCount 的值是条件中的记录总数,而不是所有的记录数.
这个@where参数该如何添上?
谢谢.
...全文
相关推荐
AspNetPager分页控件 存储过程
在本文中,我们将详细探讨如何使用AspNetPager分页控件与存储过程相结合来处理数据分页。
AspNetPager+存储过程分页
AspNetPager+存储过程分页结合第三方控件AspNetPager控件的扩展界面和存储过程大批量数据的处理,本程序适合新手研究
AspNetPager分页控件+存储过程应用之SQL Server
分页控件在Web开发中的作用在于,当网页需要显示的数据量过大时,为了避免一次性加载所有数据导致页面响应速度慢,可以将数据分为多个部分(页)按需加载。
Repeater+AspNetPager利用存储过程实现分页
该项目利用Repeater控件与AspNetPager组件结合存储过程实现数据分页功能,主要用于展示学员信息列表,包含学员编号、姓名、年龄、联系方式等字段,并支持查看、编辑和删除操作,适用于ASP.N
AspNetPager分页控件存储过程代码
在标题提到的“存储过程代码”中,我们可以看到AspNetPager如何与数据库中的存储过程协同工作来实现数据的分页显示。首先,我们需要理解什么是存储过程。


