发布于 2016-05-31 07:37:31 | 88 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

ASP.NET

ASP.NET 是.NET FrameWork的一部分,是一项微软公司的技术,是一种使嵌入网页中的脚本可由因特网服务器执行的服务器端脚本技术,它可以在通过HTTP请求文档时再在Web服务器上动态创建它们。 指 Active Server Pages(动态服务器页面) ,运行于 IIS(Internet Information Server 服务,是Windows开发的Web服务器)之中的程序 。


在asp.net 网页中如果在业务逻辑层分页在使用PagedDataSource对象,但如果数据记录过多,使用它会严重的损害应用程序的性能.
所以最好在数据访层分页,如果这样就要使用存储过程来分页.以下是以pubs 数据库中的employee表为例来进行数据分页的存储过程,你可以参考它根据实际情况来创建自己的存储过程.

注:@pageindex 数据页的索引,@dataperpage 每页的记录数目,@howmanyrecords 用来获取总的记录数.
 
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 函数可以给检索来的每条记录按照排序来编号.

接下来你就可以在asp.net 网页后台代码中调用该存储过程,就可以获取想要的数据.

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务