aspnetpager 的查询 分页 问题 悬赏100
就是用的陕北吴旗娃的分页控件,大家帮帮忙
CREATE procedure RPhone_page
(@pagesize int,
@pageindex int,
@docount bit,
@sj1 varchar(20),
@sj2 varchar(20))
as
set nocount on
if(@docount=1)
select count(id) from RPhone
else
begin
create table #indextable(id int identity(1,1),nid int)
declare @PageLowerBound int
declare @PageUpperBound int
set @PageLowerBound=(@pageindex-1)*@pagesize
set @PageUpperBound=@PageLowerBound+@pagesize
set rowcount @PageUpperBound
insert into #indextable(nid) select id from RPhone order by Pdate desc
if(@sj1=""and @sj2="")
begin
select O.id,O.cid,O.Pdate,O.Pphone ,substring(O.Pmemo,0,6) as dd ,O.Pmemo from RPhone O,#indextable t where O.id=t.nid
and t.id>@PageLowerBound and t.id<=@PageUpperBound order by t.id
end
if(@sj1!="")
begin
select O.id,O.cid,O.Pdate,O.Pphone,substring(O.Pmemo,0,6) as dd,o.Pmemo from RPhone O,#indextable t where O.id=t.nid
and t.id>@PageLowerBound and t.id<=@PageUpperBound and convert(varchar(12),Pdate,112) >=convert(varchar(12),@sj1,112)order by t.id
end
if(@sj2!="")
begin
select O.id,O.cid,O.Pdate,O.Pphone,substring(O.Pmemo,0,6) as dd ,O.Pmemo from RPhone O,#indextable t where O.id=t.nid
and t.id>@PageLowerBound and t.id<=@PageUpperBound and convert(varchar(12),Pdate,112) <=convert(varchar(12),@sj2,112)order by t.id
end
if(@sj2!="" and @sj1!="")
begin
select O.id,O.cid,O.Pdate,O.Pphone,substring(O.Pmemo,0,6) as dd ,O.Pmemo from RPhone O,#indextable t where O.id=t.nid
and t.id>@PageLowerBound and t.id<=@PageUpperBound and convert(varchar(12),@sj1,112) <= convert(varchar(12),Pdate,112) and convert(varchar(12),Pdate,112) <=convert(varchar(12),@sj2,112) order by t.id
end
end
set nocount off
GO
我像这样做后,条件变后就是总页数,记录数不变,