加入收藏 | 设为首页 | 会员中心 | 我要投稿 聊城站长网 (https://www.0635zz.com/)- 智能语音交互、行业智能、AI应用、云计算、5G!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

asp又一个分页的代码案例

发布时间:2023-09-23 15:05:08 所属栏目:Asp教程 来源:
导读:一个分页代码例子

<%&#39;&#39;本程序文件名为:Pages.asp%>

<%&#39;&#39;包含ADO常量表文件adovbs.inc,可从"/Program Files/Common Files/System/ADO"目录下拷贝%>

<!--#Include File="adovbs.inc"-->
一个分页代码例子
 
<%''本程序文件名为:Pages.asp%>
 
<%''包含ADO常量表文件adovbs.inc,可从"/Program Files/Common Files/System/ADO"目录下拷贝%>
 
<!--#Include File="adovbs.inc"-->
 
<%''*建立数据库连接,这里是Oracle8.05数据库
 
Set conn=Server.CreateObject("ADODB.Connection")
 
conn.Open "Provider=msdaora.1;Data Source=YourSrcName;User ID=YourUserID;Password=YourPassword;"
 
Set rs=Server.CreateObject("ADODB.Recordset") ''创建Recordset对象
 
rs.CursorLocation=adUseClient ''设定记录集指针属性
 
''*设定一页内的记录总数,可根据需要进行调整
 
rs.PageSize=10
 
''*设置查询语句
 
StrSQL="Select ID,姓名,住址,电话 from 通讯录 Order By ID"
 
rs.Open StrSQL,conn,adOpenStatic,adLockReadOnly,adCmdText
 
%>
 
<HTML>
 
<HEAD>
 
<title>分页示例</title>
 
<script language=javascript>
 
//点击"[第一页]"时响应:
 
function PageFirst()
 
{
 
document.MyForm.CurrentPage.selectedIndex=0;
 
document.MyForm.CurrentPage.onchange();
 
}
 
//点击"[上一页]"时响应:
 
function PagePrior()
 
{
 
document.MyForm.CurrentPage.selectedIndex--;
 
document.MyForm.CurrentPage.onchange();
 
}
 
//点击"[下一页]"时响应:
 
function PageNext()
 
{
 
document.MyForm.CurrentPage.selectedIndex++;
 
document.MyForm.CurrentPage.onchange();
 
}
 
//点击"[最后一页]"时响应:
 
function PageLast()
 
{
 
document.MyForm.CurrentPage.selectedIndex=document.MyForm.CurrentPage.length-1;
 
document.MyForm.CurrentPage.onchange();
 
}
 
//选择"第?页"时响应:
 
function PageCurrent()
 
{ //Pages.asp是本程序的文件名
 
document.MyForm.action='Pages.asp?Page='+(document.MyForm.CurrentPage.selectedIndex+1)
 
document.MyForm.submit();
 
}
 
</Script>
 
</HEAD>
 
<BODY bgcolor="#ffffcc" link="#008000" vlink="#008000" alink="#FF0000"">
 
<%IF rs.Eof THEN
 
Response.Write("<font size=2 color=#000080>[数据库中没有记录!]</font>")
 
ELSE
 
''指定当前页码
 
If Request("CurrentPage")="" Then
 
rs.AbsolutePage=1
 
Else
 
rs.AbsolutePage=CLng(Request("CurrentPage"))
 
End If
 
''创建表单MyForm,方法为Get
 
Response.Write("<form method=Get name=MyForm>")
 
Response.Write("<p align=center><font size=2 color=#008000>")
 
''设置翻页超链接
 
if rs.PageCount=1 then
 
Response.Write("[第一页] [上一页] [下一页] [最后一页] ")
 
else
 
if rs.AbsolutePage=1 then
 
Response.Write("[第一页] [上一页] ")
 
 

(编辑:聊城站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章