最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2009年12月20日 02:13:45   作者:  
在asp.net 網(wǎng)頁中如果在業(yè)務(wù)邏輯層分頁在使用PagedDataSource對象,但如果數(shù)據(jù)記錄過多,使用它會嚴(yán)重的損害應(yīng)用程序的性能.
所以最好在數(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ù).

相關(guān)文章

最新評論

定陶县| 包头市| 怀来县| 临桂县| 繁昌县| 昌平区| 周宁县| 东乡县| 溧阳市| 墨竹工卡县| 临清市| 泸溪县| 呼伦贝尔市| 敦化市| 三河市| 定州市| 南部县| 棋牌| 彝良县| 隆尧县| 江西省| 都昌县| 哈巴河县| 德惠市| 西丰县| 金华市| 龙海市| 呼和浩特市| 涿州市| 韶关市| 车致| 曲水县| 宜黄县| 大关县| 姜堰市| 新巴尔虎右旗| 遵义市| 读书| 饶河县| 宜君县| 浮山县|