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

asp.net 數(shù)據(jù)訪問(wèn)層 存儲(chǔ)過(guò)程分頁(yè)語(yǔ)句

 更新時(shí)間:2009年12月20日 02:13:45   作者:  
在asp.net 網(wǎng)頁(yè)中如果在業(yè)務(wù)邏輯層分頁(yè)在使用PagedDataSource對(duì)象,但如果數(shù)據(jù)記錄過(guò)多,使用它會(huì)嚴(yán)重的損害應(yīng)用程序的性能.
所以最好在數(shù)據(jù)訪層分頁(yè),如果這樣就要使用存儲(chǔ)過(guò)程來(lái)分頁(yè).以下是以pubs 數(shù)據(jù)庫(kù)中的employee表為例來(lái)進(jìn)行數(shù)據(jù)分頁(yè)的存儲(chǔ)過(guò)程,你可以參考它根據(jù)實(shí)際情況來(lái)創(chuàng)建自己的存儲(chǔ)過(guò)程.

注:@pageindex 數(shù)據(jù)頁(yè)的索引,@dataperpage 每頁(yè)的記錄數(shù)目,@howmanyrecords 用來(lái)獲取總的記錄數(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ù)可以給檢索來(lái)的每條記錄按照排序來(lái)編號(hào).

接下來(lái)你就可以在asp.net 網(wǎng)頁(yè)后臺(tái)代碼中調(diào)用該存儲(chǔ)過(guò)程,就可以獲取想要的數(shù)據(jù).

相關(guān)文章

最新評(píng)論

伊宁县| 南华县| 江口县| 嫩江县| 黄龙县| 晋州市| 原平市| 寻甸| 精河县| 萍乡市| 沙坪坝区| 都安| 定边县| 隆尧县| 横山县| 巴中市| 阳东县| 滁州市| 齐齐哈尔市| 隆林| 铜川市| 贵阳市| 乳山市| 绥滨县| 论坛| 准格尔旗| 阿巴嘎旗| 甘洛县| 定远县| 宣汉县| 舞钢市| 拜城县| 永春县| 涿鹿县| 九江县| 宕昌县| 厦门市| 鄂温| 太和县| 白朗县| 香河县|