<%zd=trim(Request.Form("zd"))
input=trim(Request.Form("input"))
%>
<%Set Conn=Server.CreateObject("ADODB.Connection")%>
<%Conn.Open"LocalServer","sa","iloveyou"%>
<%
set rs=server.CreateObject("adodb.recordset")
temp="select * from bib where "&zd&" like'%"&input&"%'"
rs.open temp,conn,1,2
%>
<%
const MaxPerPage=2 '单独页最大记录数 const 用来申明常量
dim sql
dim rs
dim totalPut '总记录
dim CurrentPage '当前页次
dim TotalPages '总页数
dim i
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<!-- 分页功能代码块,可独立使用 -->
<%
rs.MoveFirst '注意放到前面来,否则到任何页总是在第一个记录上
rs.pagesize=MaxPerPage '设置每页最多显示多少条记录
If trim(Request("Page"))<>"" then '如果请求的页次不为空
CurrentPage= CLng(request("Page")) 'clng是转换成长整型数据类型,并赋值到当前页次上
If CurrentPage> rs.PageCount then '如果当前页次大于总页数,则将最大页次赋值到当前页次上
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1 '一切条件不成立,将当前页设为第一页
End If
totalPut=rs.recordcount '将总记录赋值于TOTALPUT
if CurrentPage<>1 then '如果当前页数不等于第一页
if (currentPage-1)*MaxPerPage<totalPut then '如果当前页减一乘以每页最大的记录数小于总记录的话
rs.move(currentPage-1)*MaxPerPage '相对当前记录数向后移动
dim bookmark '定义书签变量
bookmark=rs.bookmark '将当前记录的标签赋于变量BOOKMARK上
end if
end if
dim n,k
if (totalPut mod MaxPerPage)=0 then '总记录数与每页最大记录数求余的结果为零时,则N返回整数页次,否则再加一.
n= totalPut / MaxPerPage
else
n= totalPut / MaxPerPage + 1
end if
%>
<%
i=0
Do While Not rs.EOF and i<maxperpage
%>
<% = rs("_题名") %>
<%
i=i+1
rs.MoveNext
Loop
%>
<table width="700" border="0" cellpadding="3" class="tbline">
<tr>
<td width="412" valign="bottom">
<!-- 分页显示代码块 可独立使用,注意和上面分页功能代码配使用 -->
<div align="center">当前第<%=currentpage%>页 总共<%=n%>页 共<%=rs.recordcount%>个留言
<%k=currentPage
if k<>1 then
response.write "[<b>"+"<a href='a1.asp?page=1&zd="&trim(Request.Form("zd"))&"&input="&trim(Request.Form("input"))&"'>首页</a></b>] "
response.write "[<b>"+"<a href='a1.asp?page="&cstr(k-1)&"&zd="&trim(Request.Form("zd"))&"&input="&trim(Request.Form("input"))&"'>上一页</a></b>] "
else
Response.Write "[首页] [上一页]"
end if
if k<>n then
response.write "[<b>"+"<a href='a1.asp?page="&cstr(k+1)&"&zd="&trim(Request.Form("zd"))&"&input="&trim(Request.Form("input"))&"'>下一页</a></b>] "
response.write "[<b>"+"<a href='a1.asp?page="&cstr(n)&"&zd="&trim(Request.Form("zd"))&"&input="&trim(Request.Form("input"))&"'>尾页</a></b>] "
else
Response.Write "[下一页] [尾页]"
end if
%>
</div></td><form method=POST action=fence.asp name=setPagesList>
<td width="68" valign="bottom">
<input type=text name=page size=5 maxlength=10 value="<%= currentpage %>"></td>
</form>
</tr>
</table>
</body>
</html>
<% rs.close
set rs=nothing
conn.close
set conn=nothing %>
请各位大侠帮帮忙看一下.在下谢谢了
可以显示第一页,但是点击下一页就报错:
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]在关键字 'like' 附近有语法错误。
/fangwenliang/serveces1/a1.asp, 第 13 行
都不知道怎么改?