给你一个我曾经做过的一个例子吧,我作的是asp,可以分页现实,也可以在文本框内输入要到的页数,然后到你想到的页数,还有一定的搜索功能。页面中用到了CSS层,你要自己改一下。至于adovbs.inc文件,在你的电脑中搜索吧,一般在你装VB的目录下有。至于页面中的数据库什么的,你都自己改一下吧,我实在是懒得自己改了。文件名luntan.asp.祝你好运! <% @language=vbscript%> <!--#include file="adovbs.inc"--> <% dim conn,rs1,strcn Response.Expires =0 dim RecordPerPage,absPageNum,TotalPages,absRecordNum recordperpage=10 if Request.ServerVariables ("content_length")=0 then abspagenum=1 else absPageNum = CInt(Request.Form("PressPageNum")) If Request.Form("Submit") = "上一页" Then absPageNum = absPageNum - 1 ElseIf Request.Form("Submit") = "下一页" Then absPageNum = absPageNum + 1 end if end if set conn=server.CreateObject ("adodb.connection") set rs1=server.CreateObject ("adodb.recordset") rs1.CursorType =adOpenStatic rs1.LockType =adLockOptimistic rs1.CacheSize = RecordPerPage conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= "& server.mappath("luntan.mdb") & ";Persist Security Info=false" %> <%cp=request.form("title") sql="select * from lt where title like '%"&cp&"%' and hfto=0 order by time desc" %> <% if cp="" then rs1.open "select * from lt where hfto=0 order by time desc",conn,1,1 else rs1.open sql,conn,1,1 if rs1.eof or rs1.bof then response.write "对不起,没有查询到您需要的内容!" response.end end if if rs1.eof and cp<>"" then response.write "对不起,没有查询到您需要的内容!" response.end end if end if rs1.pagesize=10 if Request.ServerVariables ("content_length")<>0 then if Request.Form("gotopage")<>"" then if Request.Form("gotopage")<="1" then absPageNum=1 elseif Request.Form ("gotopage")>rs1.PageCount then absPageNum=rs1.PageCount else absPageNum=Request.Form ("gotopage") end if end if end if if Request.ServerVariables ("content_length")=0 then abspagenum=1 else absPageNum = CInt(Request.Form("PressPageNum")) If Request.Form("Submit") = "上一页" Then absPageNum = absPageNum - 1 ElseIf Request.Form("Submit") = "下一页" Then absPageNum = absPageNum + 1 end if end if if abspagenum=0 then abspagenum=1 end if If Not(rs1.EOF) Then rs1.AbsolutePage =abspagenum end if TotalPages = rs1.PageCount %> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <title>欢迎光临学习论坛</title> </head><body> <p align=center>欢迎光临本站论坛! <p align=center><a href="luntan.asp">回首页</a><table width="100%" border="0" cellpadding="3" cellspacing="1"> <tr> <td width=30%> <p align=center><a href="addnew.asp">发表文章 </td > <td width=40%> <form name="form1" method="post" action="luntan.asp"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="41%"> <p align="center"> 搜索文章
你好!我现在也是那样做的!但问题是我输入了一个值!要设置cursorlocation的值!但我设置为aduserclient时,却报错!为啥???
我在asp里创建了一个recordset 时,设置了recordset.cursorlocation=aduseclient
在是打开此resordset! 设置他的pagesize=10
recordset.absolutepage=4
但asp却报错!!
为何??
<% @language=vbscript%>
<!--#include file="adovbs.inc"-->
<%
dim conn,rs1,strcn
Response.Expires =0
dim RecordPerPage,absPageNum,TotalPages,absRecordNum
recordperpage=10
if Request.ServerVariables ("content_length")=0 then
abspagenum=1
else
absPageNum = CInt(Request.Form("PressPageNum"))
If Request.Form("Submit") = "上一页" Then
absPageNum = absPageNum - 1
ElseIf Request.Form("Submit") = "下一页" Then
absPageNum = absPageNum + 1
end if
end if
set conn=server.CreateObject ("adodb.connection")
set rs1=server.CreateObject ("adodb.recordset")
rs1.CursorType =adOpenStatic
rs1.LockType =adLockOptimistic
rs1.CacheSize = RecordPerPage
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= "& server.mappath("luntan.mdb") & ";Persist Security Info=false"
%>
<%cp=request.form("title")
sql="select * from lt where title like '%"&cp&"%' and hfto=0 order by time desc"
%>
<%
if cp="" then
rs1.open "select * from lt where hfto=0 order by time desc",conn,1,1
else
rs1.open sql,conn,1,1
if rs1.eof or rs1.bof then
response.write "对不起,没有查询到您需要的内容!"
response.end
end if
if rs1.eof and cp<>"" then
response.write "对不起,没有查询到您需要的内容!"
response.end
end if
end if
rs1.pagesize=10
if Request.ServerVariables ("content_length")<>0 then
if Request.Form("gotopage")<>"" then
if Request.Form("gotopage")<="1" then
absPageNum=1
elseif Request.Form ("gotopage")>rs1.PageCount then
absPageNum=rs1.PageCount
else
absPageNum=Request.Form ("gotopage")
end if
end if
end if
if Request.ServerVariables ("content_length")=0 then
abspagenum=1
else
absPageNum = CInt(Request.Form("PressPageNum"))
If Request.Form("Submit") = "上一页" Then
absPageNum = absPageNum - 1
ElseIf Request.Form("Submit") = "下一页" Then
absPageNum = absPageNum + 1
end if
end if
if abspagenum=0 then
abspagenum=1
end if
If Not(rs1.EOF) Then
rs1.AbsolutePage =abspagenum
end if
TotalPages = rs1.PageCount
%>
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<title>欢迎光临学习论坛</title>
</head><body>
<p align=center>欢迎光临本站论坛!
<p align=center><a href="luntan.asp">回首页</a><table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr>
<td width=30%>
<p align=center><a href="addnew.asp">发表文章
</td >
<td width=40%>
<form name="form1" method="post" action="luntan.asp">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="41%"> <p align="center"> 搜索文章
<input type="text" name="title">
<input type="image" name="Submit" src="image/jump.gif" id="go">
</td>
</tr>
</table>
</form>
</td>
<td width=30%>
<p align=center><a href="login.asp">管理员登录
</td></tr>
</table>
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr>
<td width="4%" bgcolor="#0099cc">
<div align="center"><b></b></div>
</td>
<td width="35%" bgcolor="#0099cc">
<div align="center"><b><font color="#FFFFFF">主题</font></b></div>
</td>
<td width="15%" bgcolor="#0099cc">
<div align="center"><b><font color="#FFFFFF">作 者</font></b></div>
</td>
<td width="14%" bgcolor="#0099cc">
<div align="center"><b><font color="#FFFFFF">发表时间</font></b></div>
</td>
<td width="8%" bgcolor="#0099cc">
<div align="center"><b><font color="#FFFFFF">阅读数</font></b></div>
</td>
<td width="8%" bgcolor="#0099cc">
<div align="center"><b><font color="#FFFFFF">回复数</font></b></div>
</td>
</tr>
<tr>
</tr>
<% Do while not rs1.eof
if n=rs1.pagesize then exit do %>
<tr>
<td width="4%">
<div align="center"><img src="image/smile/<%=rs1("face")%>.gif"></div>
</td>
<td width="35%">
<div align="left"><a href="detail.asp?id=<%=rs1("id")%>" target="_blank"><img src="image/newwin.gif" width="14" height="11" border="0"></a> <a href="detail.asp?id=<%=rs1("id")%>" title="<%=rs1("title")%>"><%=left(rs1("title"),30)%></a></div>
</td>
<td width="15%">
<div align="center"><%=rs1("name")%></a></div>
</td>
<td width="14%">
<div align="left"><%=rs1("time")%></div>
</td>
<td width="8%">
<div align="center"><%=rs1("yds")%></div>
</td>
<td width="8%">
<div align="center"><%=rs1("hfs")%></div>
</td>
</tr>
<%rs1.movenext
n=n+1
Loop%>
</table>
<hr size="1">
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr>
<td width=10%>
<p align=right>
<Form id="submitto" name="what" action ="<%= Request.ServerVariables("SCRIPT_NAME") %>" onsubmit="Validate(); return false;" language="Visual Basic Scripting Edition" Method="Post">
<td width=30%>
<p align=center>到第<input type="text" name="gotopage" size=3>页
</td>
</Form><td width=30%>
<p align=center>
<Center> [ 第 <font color="#CC0033"><%= absPageNum %></font> 页,
共 <font color="#CC0033"><%= TotalPages %></font> 页 ] </Center>
</td>
<td width=30%>
<p align=right><Form Action = "<%= Request.ServerVariables("SCRIPT_NAME") %>" Method="Post" id=form1 name=form1>
<Input Type="Hidden" Name="PressPageNum" Value="<%= absPageNum%>">
<%
If absPageNum > 1 Then %>
<td>
<p align=right><Input Type="Submit" Name="Submit" Value="上一页" class="botton"><br>
</td>
<% End If
If absPageNum <> TotalPages Then %>
<td>
<p align=right><Input Type="Submit" Name="Submit" Value="下一页" class="botton"><br>
</td>
<% End If %>
</Form>
</td>
</tr>
</table>
<% rs1.Close
conn.Close
set rs1=nothing
set conn=nothing
%>
</body>
</html>