注:@pageindex 數(shù)據(jù)頁的索引,@dataperp " /> 亚洲免费专区,亚洲蜜臀av乱码久久精品,一区二区三区黄色

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

asp.net 數(shù)據(jù)訪問層 存儲過程分頁語句

所以最好在數(shù)據(jù)訪層分頁,如果這樣就要使用存儲過程來分頁.以下是以pubs 數(shù)據(jù)庫中的employee表為例來進行數(shù)據(jù)分頁的存儲過程,你可以參考它根據(jù)實際情況來創(chuàng)建自己的存儲過程.

注:@pageindex 數(shù)據(jù)頁的索引,@dataperpage 每頁的記錄數(shù)目,@howmanyrecords 用來獲取總的記錄數(shù).
復(fù)制代碼 代碼如下:
create proc getdata @pageindex int,@dataperpage int,@howmanyrecords int output
as
declare @temptable table
(
rowindex int,
emp_id char(9),
fname varchar(20),
minit char(1),
lname varchar(30)
)
insert into @temptable
select row_number() over(order by emp_id) as rowindex,emp_id,fname,minit,lname
from employee
select @howmanyrecords=count(rowindex) from @temptable
select * from @temptable
where rowindex>(@pageindex-1)*@dataperpage
and rowindex<=@pageindex*@dataperpage

declare @howmanyrecords int
exec getdata 2,5,@howmanyrecords output
select @howmanyrecords
declare @x int, @y int, @z int
select @x = 1, @y = 2, @z=3
select @x,@y,@z

create proc getdata2 @pageindex int,@dataperpage int,@howmanyrecords int output
as
declare @temptable table
(
rowindex int,
emp_id char(9),
fname varchar(20),
minit char(1),
lname varchar(30)
)
insert into @temptable
select row_number() over(order by emp_id) as rowindex,emp_id,fname,minit,lname
from employee
select @howmanyrecords=count(rowindex) from @temptable
select * from @temptable
where rowindex>(@pageindex-1)*@dataperpage
and rowindex<=@pageindex*@dataperpage

其中Row_number 函數(shù)可以給檢索來的每條記錄按照排序來編號.

接下來你就可以在ASP.NET 網(wǎng)頁后臺代碼中調(diào)用該存儲過程,就可以獲取想要的數(shù)據(jù).

AspNet技術(shù)asp.net 數(shù)據(jù)訪問層 存儲過程分頁語句,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 瑞金市| 岳阳市| 雅安市| 定安县| 连山| 怀安县| 东海县| 赤峰市| 肥西县| 紫阳县| 古田县| 惠水县| 任丘市| 崇阳县| 武威市| 巴林左旗| 会宁县| 大城县| 蓬莱市| 平湖市| 莱芜市| 文安县| 集贤县| 永靖县| 共和县| 安溪县| 肥乡县| 凤凰县| 双江| 阿勒泰市| 峡江县| 富蕴县| 天门市| 星座| 开封县| 溆浦县| 资源县| 云安县| 武功县| 盐津县| 宣恩县|