做了一个ASP代码的搜索,分页的时候第一页能显示,第二页显示不了内容。谁能帮我解决掉啊。谢谢了加10分
table表头<%dimactact=request("act")if(act="search")thenQueryString=Request.form("QueryS...
table表头
<%
dim act
act=request("act")
if(act="search") then
QueryString = Request.form( "QueryString" )
QueryWords = Split( QueryString )
strIndent = " "
' 如果搜索为空则返回
If QueryString = "" Then
Response.Redirect( "ocj.asp" )
End If
Session.timeout = 5
If IsObject(Session("sitesearch_conn")) Then
Set conn = Session("sitesearch_conn")
Else
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("ga1.mdb"),"",""
End If
' 查询语句
sql = "SELECT * FROM [all] WHERE"
'搜索Description字段
sql = sql & " ( [序号] LIKE '%" & QueryWords( 0 ) & "%'" ' First
For i = LBound( QueryWords ) + 1 to UBound( QueryWords )
If QueryWords( i ) <> "" and UCase( QueryWords(i) ) <> "OR" and UCase( QueryWords(i) ) <> "AND" Then
If uCase( QueryWords( i-1 ) ) = "OR" Then
sql = sql & " OR [序号] LIKE '%" & QueryWords( i ) & "%'"
Else
sql = sql & " AND [序号] LIKE '%" & QueryWords( i ) & "%'"
End If
End If
Next
' 搜索Keywords字段
sql = sql & " ) OR ( [供应商代码] LIKE '%" & QueryWords( 0 ) & "%'"
For i = LBound( QueryWords ) + 1 to UBound( QueryWords )
If QueryWords( i ) <> "" and UCase( QueryWords(i) ) <> "OR" and UCase( QueryWords(i) ) <> "AND" Then
If uCase( QueryWords( i-1 ) ) = "OR" Then
sql = sql & " OR [供应商代码] LIKE '%" & QueryWords( i ) & "%'"
Else
sql = sql & " AND [供应商代码] LIKE '%" & QueryWords( i ) & "%'"
End If
End If
Next
' 搜索Title字段
sql = sql & " ) OR ( [供应商名称] LIKE '%" & QueryWords( 0 ) & "%'"
For i = LBound( QueryWords ) + 1 to UBound( QueryWords )
If QueryWords( i ) <> "" and UCase( QueryWords(i) ) <> "OR" and UCase( QueryWords(i) ) <> "AND" Then
If uCase( QueryWords( i-1 ) ) = "OR" Then
sql = sql & " OR [供应商名称] LIKE '%" & QueryWords( i ) & "%'"
Else
sql = sql & " AND [供应商名称] LIKE '%" & QueryWords( i ) & "%'"
End If
End If
Next
sql = sql & " ) "
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn,3,3
if rs.bof and rs.eof then
response.write "没有找到相关信息!!"
else
rs.pagesize=14
if request("page")<>"" then
epage=cint(request("page"))
if epage<1 then epage=1
if epage>rs.pagecount then epage=rs.pagecount
else
epage=1
end if
rs.absolutepage=epage
%>
<%
for i=0 to rs.pagesize-1
if rs.bof or rs.eof then exit for
%>
table表格
<%
rs.movenext()
next
%>
<p align="center">
<a href="searchga.asp?">首页</a>
<a href="searchga.asp?page=<%=epage-1%>">前一页</a>
<a href="searchga.asp?page=<%=epage+1%>">后一页</a>
<a href="searchga.asp?page=<%=rs.pagecount%>">末页</a>
</p>
<p align="center">现在是第<%=epage%>页一共有<%=rs.pagecount%>页</p>
<%
rs.close
Set rs = Nothing
conn.close
set conn=nothing
end if
%>
<%end if%>
</body>
</html>
这段代码写入以后:
<p align="center">
<a href="searchga.asp?page=1&QueryWords<%=QueryWords%>&act=search">首页</a>
<a href="searchga.asp?page=<%=epage-1%>&QueryWords=<%=QueryWords%>&act=search">前一页</a>
<a href="searchga.asp?page=<%=epage+1%>&QueryWords<%=QueryWords%>&act=search">
">后一页</a>
<a href="searchga.asp?page=<%=rs.pagecount%>&QueryWords<%=QueryWords%>&act=search">
">末页</a>
结果:
错误类型:
Response 对象, ASP 0106 (0x80020005)
遇到未处理的数据类型。
/searchga.asp
还是不多,还的请各位给个修改后能翻页传值的代码。谢谢了 展开
<%
dim act
act=request("act")
if(act="search") then
QueryString = Request.form( "QueryString" )
QueryWords = Split( QueryString )
strIndent = " "
' 如果搜索为空则返回
If QueryString = "" Then
Response.Redirect( "ocj.asp" )
End If
Session.timeout = 5
If IsObject(Session("sitesearch_conn")) Then
Set conn = Session("sitesearch_conn")
Else
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("ga1.mdb"),"",""
End If
' 查询语句
sql = "SELECT * FROM [all] WHERE"
'搜索Description字段
sql = sql & " ( [序号] LIKE '%" & QueryWords( 0 ) & "%'" ' First
For i = LBound( QueryWords ) + 1 to UBound( QueryWords )
If QueryWords( i ) <> "" and UCase( QueryWords(i) ) <> "OR" and UCase( QueryWords(i) ) <> "AND" Then
If uCase( QueryWords( i-1 ) ) = "OR" Then
sql = sql & " OR [序号] LIKE '%" & QueryWords( i ) & "%'"
Else
sql = sql & " AND [序号] LIKE '%" & QueryWords( i ) & "%'"
End If
End If
Next
' 搜索Keywords字段
sql = sql & " ) OR ( [供应商代码] LIKE '%" & QueryWords( 0 ) & "%'"
For i = LBound( QueryWords ) + 1 to UBound( QueryWords )
If QueryWords( i ) <> "" and UCase( QueryWords(i) ) <> "OR" and UCase( QueryWords(i) ) <> "AND" Then
If uCase( QueryWords( i-1 ) ) = "OR" Then
sql = sql & " OR [供应商代码] LIKE '%" & QueryWords( i ) & "%'"
Else
sql = sql & " AND [供应商代码] LIKE '%" & QueryWords( i ) & "%'"
End If
End If
Next
' 搜索Title字段
sql = sql & " ) OR ( [供应商名称] LIKE '%" & QueryWords( 0 ) & "%'"
For i = LBound( QueryWords ) + 1 to UBound( QueryWords )
If QueryWords( i ) <> "" and UCase( QueryWords(i) ) <> "OR" and UCase( QueryWords(i) ) <> "AND" Then
If uCase( QueryWords( i-1 ) ) = "OR" Then
sql = sql & " OR [供应商名称] LIKE '%" & QueryWords( i ) & "%'"
Else
sql = sql & " AND [供应商名称] LIKE '%" & QueryWords( i ) & "%'"
End If
End If
Next
sql = sql & " ) "
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn,3,3
if rs.bof and rs.eof then
response.write "没有找到相关信息!!"
else
rs.pagesize=14
if request("page")<>"" then
epage=cint(request("page"))
if epage<1 then epage=1
if epage>rs.pagecount then epage=rs.pagecount
else
epage=1
end if
rs.absolutepage=epage
%>
<%
for i=0 to rs.pagesize-1
if rs.bof or rs.eof then exit for
%>
table表格
<%
rs.movenext()
next
%>
<p align="center">
<a href="searchga.asp?">首页</a>
<a href="searchga.asp?page=<%=epage-1%>">前一页</a>
<a href="searchga.asp?page=<%=epage+1%>">后一页</a>
<a href="searchga.asp?page=<%=rs.pagecount%>">末页</a>
</p>
<p align="center">现在是第<%=epage%>页一共有<%=rs.pagecount%>页</p>
<%
rs.close
Set rs = Nothing
conn.close
set conn=nothing
end if
%>
<%end if%>
</body>
</html>
这段代码写入以后:
<p align="center">
<a href="searchga.asp?page=1&QueryWords<%=QueryWords%>&act=search">首页</a>
<a href="searchga.asp?page=<%=epage-1%>&QueryWords=<%=QueryWords%>&act=search">前一页</a>
<a href="searchga.asp?page=<%=epage+1%>&QueryWords<%=QueryWords%>&act=search">
">后一页</a>
<a href="searchga.asp?page=<%=rs.pagecount%>&QueryWords<%=QueryWords%>&act=search">
">末页</a>
结果:
错误类型:
Response 对象, ASP 0106 (0x80020005)
遇到未处理的数据类型。
/searchga.asp
还是不多,还的请各位给个修改后能翻页传值的代码。谢谢了 展开
4个回答
展开全部
<p align="center">
<a href="searchga.asp?">首页</a>
<a href="searchga.asp?page=<%=epage-1%>">前一页</a>
<a href="searchga.asp?page=<%=epage+1%>">后一页</a>
<a href="searchga.asp?page=<%=rs.pagecount%>">末页</a>
改成
<p align="center">
<a href="searchga.asp?">首页</a>
<a href="searchga.asp?page=<%=epage-1%>&QueryWords=<%=QueryWords%>">前一页</a>
<a href="searchga.asp?page=<%=epage+1%>&QueryWords<%=QueryWords%>">
">后一页</a>
<a href="searchga.asp?page=<%=rs.pagecount%>&QueryWords<%=QueryWords%>">
">末页</a>
试试?? 因为你传到下一页没有把参数传过去!所以到第二页就成了空值!所以显示出不来!
加我QQ帮你看看 280118377
<a href="searchga.asp?">首页</a>
<a href="searchga.asp?page=<%=epage-1%>">前一页</a>
<a href="searchga.asp?page=<%=epage+1%>">后一页</a>
<a href="searchga.asp?page=<%=rs.pagecount%>">末页</a>
改成
<p align="center">
<a href="searchga.asp?">首页</a>
<a href="searchga.asp?page=<%=epage-1%>&QueryWords=<%=QueryWords%>">前一页</a>
<a href="searchga.asp?page=<%=epage+1%>&QueryWords<%=QueryWords%>">
">后一页</a>
<a href="searchga.asp?page=<%=rs.pagecount%>&QueryWords<%=QueryWords%>">
">末页</a>
试试?? 因为你传到下一页没有把参数传过去!所以到第二页就成了空值!所以显示出不来!
加我QQ帮你看看 280118377
展开全部
少传了 关键值的 参数
现在你只传了页码,但是你的程序前面有接收并判断搜索关键字,而你这个关键值在转到第二页却没有,所以关键值变成了空
现在你只传了页码,但是你的程序前面有接收并判断搜索关键字,而你这个关键值在转到第二页却没有,所以关键值变成了空
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<p align="center">
<a href="searchga.asp?page=1&QueryWords<%=QueryWords%>&act=search">首页</a>
<a href="searchga.asp?page=<%=epage-1%>&QueryWords=<%=QueryWords%>&act=search">前一页</a>
<a href="searchga.asp?page=<%=epage+1%>&QueryWords<%=QueryWords%>&act=search">
">后一页</a>
<a href="searchga.asp?page=<%=rs.pagecount%>&QueryWords<%=QueryWords%>&act=search">
">末页</a>
<a href="searchga.asp?page=1&QueryWords<%=QueryWords%>&act=search">首页</a>
<a href="searchga.asp?page=<%=epage-1%>&QueryWords=<%=QueryWords%>&act=search">前一页</a>
<a href="searchga.asp?page=<%=epage+1%>&QueryWords<%=QueryWords%>&act=search">
">后一页</a>
<a href="searchga.asp?page=<%=rs.pagecount%>&QueryWords<%=QueryWords%>&act=search">
">末页</a>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询