惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
SecWiki News
SecWiki News
Project Zero
Project Zero
C
Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Scott Helme
Scott Helme
A
Arctic Wolf
Security Latest
Security Latest
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
Apple Machine Learning Research
Apple Machine Learning Research
T
Tailwind CSS Blog
The Hacker News
The Hacker News
T
Tenable Blog
雷峰网
雷峰网
有赞技术团队
有赞技术团队
V
V2EX
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threat Research - Cisco Blogs
T
Threatpost
AWS News Blog
AWS News Blog
L
LINUX DO - 热门话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
SegmentFault 最新的问题
月光博客
月光博客
Spread Privacy
Spread Privacy
S
Secure Thoughts
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
Forbes - Security
Forbes - Security
T
The Exploit Database - CXSecurity.com
G
GRAHAM CLULEY
The Last Watchdog
The Last Watchdog
Y
Y Combinator Blog
I
Intezer
博客园 - 【当耐特】
B
Blog RSS Feed
Attack and Defense Labs
Attack and Defense Labs
I
InfoQ
博客园 - 叶小钗
Cyberwarzone
Cyberwarzone
V2EX - 技术
V2EX - 技术
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
H
Help Net Security
C
CERT Recently Published Vulnerability Notes

博客园 - symjie

每天学一点AS3.0(五)---声音的控制(5) 每天学一点AS3.0(四)---声音的控制(4) 每天学一点AS3.0(三)---声音的控制(3) 每天学一点AS3.0(二)---声音的控制(2) 每天学一点AS3.0(一)---声音的控制 Jquery json的超强组合 - symjie - 博客园 javascript分页程序 - symjie - 博客园 初试jquery制作一个简单的loading delegate——委派 - symjie - 博客园 Ajax.net和GridView交互 Ajax.net实现loading登陆的效果 - symjie - 博客园 Ajax.net+模态窗口的登陆简单例子 GridView自定义分页(vb) - symjie - 博客园 用下拉列表控制gridview的分页 DataView数据组件 (转) c#冒泡程序 Atlas学习笔记 getElementByTagsName和相关函数的学习 基于Ajax.net的验证
sql 分页
symjie · 2007-05-25 · via 博客园 - symjie

       今天在做基于ajaxpro分页的时候,发现如果按照前一篇文章所指示,和gridview交互很是不方便,于是就写了基于存储过程和DataTable的分页,主要是存储过程,我就把存储过程给出,其他的很简单,就不再列出

 1--分页存储过程
 2create procedure GetNews
 3(
 4  @type int,--文章的类型
 5  @pgs int,--页大小
 6  @pgn int--页码,页码为0为求总也数
 7)
 8as
 9declare @strsql nvarchar(500--执行的sql语句
10declare @zongshu int--纪录总数
11declare @yeshu int --总页数
12declare @strtemp int--临时变量
13if @pgn=0
14  begin
15     select @zongshu=count(*from LYNews where newstype=@type
16    if @zongshu<=@pgs
17        begin
18          if @zongshu=0
19
20                 set @yeshu=0
21            
22           else           
23             set  @yeshu=1             
24        end
25     else--如果@zongshu>@pgs那么开始计算分页,如果@zongshu%@pgs=0的话,就说明每页都是慢的,如果不是的话,那么将存在多余的占一页
26         begin
27          set @strtemp=@zongshu%@pgs  --如果@zongshu%@pgs=0的话,就说明每页都是满的,如果不是的话,那么将存在多余的纪录占一页
28           if @strtemp=0
29             
30                set @yeshu=@zongshu/@pgs
31            
32           else
33              begin
34                set @yeshu=@zongshu/@pgs+1--否则的话那么得在添加一页来显示多余的数据
35              end
36             set @strsql='select '+str(@zongshu)+' as zongshu, '+str(@yeshu)+' as yeshu'  --返回总页数和总纪录数
37          end   
38end 
39else 
40   begin
41    if @pgn=1
42      
43         set @strsql='select top '+str(@pgs)+'  * from Lynews where newstype='+str(@type)+' order by postdate desc'--返回第一页的纪录
44       
45    else
46     
47      set @strsql='select top '+str(@pgs)+' * from LyNews Where newstype='+str(@type)+' and postdate<(select min(postdate)  from (select top '+str((@pgn-1)*@pgs)+' * from  LyNews  where newstype='+str(@type)+' order by postdate desc ) as t) order by postdate desc'
48      
49   end
50exec (@strsql)
51go