| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 825 人关注过本帖
标题:请帮忙修复一下这段代码的BUG
只看楼主 加入收藏
a4620269
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-11-23
收藏
 问题点数:0 回复次数:14 
请帮忙修复一下这段代码的BUG
请帮忙修复一下这段代码的BUG
这是我找的一个搜索的源码。其他方面都非常好。

但当你直接点搜索时,再点“下一页”,BUG就出现了。跳不到下一页。显示“没有物品”。

可能是search.asp分页没有设置好。有没有高人帮我一下。

演示页面 www.zh-expo.com/asp4

源码 www.zh-expo.com/asp4/wwwroot.rar

下面是search.asp页(也就是搜索页)的源码

<!-- #Include File=Conn.asp -->
<!-- #Include File=setup.asp -->
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>
<link rel="stylesheet" type="text/css" href="style.css">
<style fprolloverstyle>a:hover { color: #FF0000 }
</style>
</head>

<%Set rst= Server.CreateObject ("ADODB.RecordSet")
sql = "select * from type"
rst.open sql,conn,1,3
%>
<!--#include file="head.asp"-->
<%
'-------------------------------------------
typeid=request("typeid")
Province=request("Province")
keyword=trim(request("name"))
wanttime=request("wanttime")

dim sql,typeid
dim rs '实例
dim totalPut '总记录数
dim CurrentPage '当前页
dim TotalPages '总页数
dim i,j

if keyword="关键字可以不输入" then
keyword=""
else
findword="name like '%"&keyword&"%' "
end if
Set rs= Server.CreateObject ("ADODB.RecordSet")
if typeid<>"b" and province<>"a" and keyword<>"" then
sql = "select * from goods where typeid='"&typeid&"'and name like '%"&keyword&"%' and province='"&province&"' and savetime>=date()-'"&wanttime&"'order by savetime desc"
elseif typeid="b" and province="a" and keyword="" and wanttime<>"" then
sql = "select * from goods where savetime>=date()-'"&wanttime&"'order by savetime desc"
elseif typeid="b" and province="a" and keyword<>"" then
sql = "select * from goods where name like '%"&keyword&"%' and savetime>=date()-'"&wanttime&"'order by savetime desc"
elseif typeid="b" and province<>"a" and keyword="" then
sql = "select * from goods where province='"&province&"'and savetime>=date()-'"&wanttime&"'order by savetime desc"
elseif typeid<>"b" and province="a" and keyword="" then
sql = "select * from goods where typeid='"&typeid&"'and savetime>=date()-'"&wanttime&"'order by savetime desc"
elseif typeid<>"b" and province<>"a" and keyword="" then
sql = "select * from goods where typeid='"&typeid&"'and province='"&province&"' and savetime>=date()-'"&wanttime&"'order by savetime desc"
elseif typeid<>"b" and province="a" and keyword<>"" then
sql = "select * from goods where typeid='"&typeid&"'and name like '%"&keyword&"%' and savetime>=date()-'"&wanttime&"'order by savetime desc"
elseif typeid="b" and province<>"a" and keyword<>"" then
sql = "select * from goods where province='"&province&"' and name like '%"&keyword&"%' and savetime>=date()-'"&wanttime&"'order by savetime desc"
end if

rs.open sql,conn,1,3

'----------------------------------
if rs.bof then
response.write " <br><br><br><br>"
response.write "<p align='center'> 没有物品 !</p>"
response.end
end if
rs.MoveFirst '到第一条记录
rs.pagesize=MaxPerPage '定义每页记录数
If trim(Request("Page"))<>"" then
CurrentPage= CLng(request("Page"))
If CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1
End If
if rs.eof then
response.write " <br><br><br><br>"
response.write "<p align='center'> 没有物品 !</p>"
response.end
else
totalPut=rs.recordcount 'totalput=总记录数
if CurrentPage<>1 then
if (currentPage-1)*MaxPerPage < totalPut then
rs.move(currentPage-1)*MaxPerPage
end if
end if
end if
%>
<body topmargin="1" leftmargin="1" link="#000000" vlink="#000000">

<table border="0" cellpadding="0" cellspacing="0" width="770" align="center">
<tr>
<td width="64"><img src="image/home.gif" width="16" height="16">
<a href="index.asp">回首页</a></td>
<td width="411" valign="bottom">
<%
if rs.pagecount <= 6 then
for j=1 to rs.pagecount
response.write "[<a href='index.asp?typeid="&typeid&"&page="&j&"'>"&j&"</a>]"
next
else
for j=1 to 8
response.write "[<a href='index.asp?typeid="&typeid&"&page="&j&"'>"&j&"</a>]&nbsp;"
next
response.write "[<a href='index.asp?typeid="&typeid&"&page="&rs.pagecount&"' title='最后一页'>&gt;&gt;</a>]"
end if
%> </td>
<td width="291">
<p align="right">
<img border="0" src="image/inboxno.gif" width="16" height="16">页数:<%=CurrentPage%>/<%=rs.pagecount%>&nbsp;&nbsp;&nbsp;<img border="0" src="image/jinghua.gif" width="13" height="16">&nbsp;商品数量:&nbsp;<%=totalPut%>
&nbsp;&nbsp;&nbsp;<img border="0" src="image/userlist1.gif" width="16" height="16">&nbsp;<a href="login.asp">版主管理</a></td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="1" width="776" align="center" height="80" bgcolor="#BB0B48">
<tr align="center">
<td class="td1" height="20" width="59" bgcolor="#00659C" align="center">
<p align="center"><font color="#FFFFFF">供或求</font></td>
<td class="td1" height="20" width="95" bgcolor="#00659C" align="center">
<font color="#FFFFFF">类型</font></td>
<td class="td1" height="20" width="261" bgcolor="#00659C" align="center">
<font color="#FFFFFF">商品名称</font></td>
<td class="td1" height="20" width="113" bgcolor="#00659C" align="center">
<font color="#FFFFFF">地区</font></td>
<td class="td1" height="20" width="58" bgcolor="#00659C" align="center">
<font color="#FFFFFF">价格</font></td>
<td class="td1" height="20" width="50" bgcolor="#00659C" align="center">
<font color="#FFFFFF">浏览</font></td>
<td class="td1" height="20" width="138" bgcolor="#00659C" align="center">
<font color="#FFFFFF">登记时间</font></td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td width="59" align="center" bgcolor="#FFF3EE" height="18">
<font color="#808000"><%=rs("buyorsell")%></font></td>
<td width="95" align="center" bgcolor="#FFF3EE" height="18"><%=rs("typeid")%></td>
<td width="261" align="center" bgcolor="#FFF3EE" height="18">
<a href="list.asp?id=<%=rs("id")%>" target="_blank"><%=rs("name")%></a><%if rs("image")<>"" then%><img border="0" src="image/tu.gif" align="absMiddle"><%end if%></td>
<td width="113" align="center" bgcolor="#FFF3EE" height="18"><%=rs("province")%>/<%=rs("city")%></td>
<td width="58" align="center" bgcolor="#FFF3EE" height="18"><%=rs("money")%></td>
<td width="50" align="center" bgcolor="#FFF3EE" height="18"><%=rs("hit")%></td>
<td width="138" align="center" bgcolor="#FFF3EE" height="18"><%=rs("savetime")%></td>
</tr>
<tr>
<td width="746" colspan="7" bgcolor="#FFF3EE" height="18">
<img border="0" src="image/inboxnonew.gif" width="16" height="16"><%=rs("conter")%></td>
</tr>
<tr>
<td width="746" colspan="7" height="16" bgcolor="#FFFFFF"> </td>
</tr>
<%i=i+1
if i>=25 then exit do
rs.movenext
loop
%>
</table>
<table border="0" cellspacing="1" width="773" align="center">
<tr>
<td class="td1" bgcolor="#00659C" width="760">
<div align="right">
<select size="1" name="D1" onchange="MM_goToURL('parent',this.value);return document.MM_returnValue">
<option>跳转页数</option>
<%
soonhost=0
DO WHILE NOT soonhost = rs.pageCount %>
<option value="view.asp?Page=<% =soonhost+1 %>"><% =soonhost+1 %></option>
<% soonhost=soonhost+1
loop
%></select>  
<%
dim n,k
if (totalPut mod MaxPerPage)=0 then 'n表示总页数
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if
k=currentPage
if k<>1 then
response.write "<b>"+"<a href='index.asp?page=1'><font color=""#FFFFFF"">[首页]</font></a></b> "
response.write "<b>"+"<a href='index.asp?typeid="+typeid+"&page="+cstr(k-1)+"'><font color=""#FFFFFF"">[上一页]</font></a></b> "
else
Response.Write "<font color=""#FFFFFF"">[首页] [上一页]</font>"
end if
if k<>n then
response.write "<b>"+"<a href='index.asp?typeid="+typeid+"&page="+cstr(k+1)+"'><font color=""#FFFFFF"">[下一页]</font></a></b> "
response.write "<b>"+"<a href='index.asp?typeid="+typeid+"&page="+cstr(n)+"'><font color=""#FFFFFF"">[尾页]</font></a></b> "
else
Response.Write "<font color=""#FFFFFF"">[下一页] [尾页]</font>"
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</div>
</td>
</tr>
</table>
<p><br>
</p>
</body>
</html>

搜索更多相关主题的帖子: BUG 代码 
2005-11-23 14:50
zmjls
Rank: 1
等 级:新手上路
帖 子:377
专家分:0
注 册:2005-9-30
收藏
得分:0 
这段代码不是很全,把另外的代码贴出来看看!!要改是没问题的!

对ASP、.NET、SQL情有独钟的情圣王子! 俺目标:睡觉睡到自然醒数钱数到手抽筋!
2005-11-23 14:56
a4620269
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-11-23
收藏
得分:0 

这段代码你不用看的
直接下载源码看看吧,这个程度写的很简单。
源码我上面有连接,你下载看看吧,谢谢了。


if I=pig and I drop off that I no dread boiled water scald end if
2005-11-23 15:01
zmjls
Rank: 1
等 级:新手上路
帖 子:377
专家分:0
注 册:2005-9-30
收藏
得分:0 
你想要改成点下一页就跳到下一页是吗?不会弹出无数据那一页!!对不对?

对ASP、.NET、SQL情有独钟的情圣王子! 俺目标:睡觉睡到自然醒数钱数到手抽筋!
2005-11-23 15:04
a4620269
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-11-23
收藏
得分:0 
是的,主要就是改这个
谢谢了

if I=pig and I drop off that I no dread boiled water scald end if
2005-11-23 15:12
zmjls
Rank: 1
等 级:新手上路
帖 子:377
专家分:0
注 册:2005-9-30
收藏
得分:0 
好,晚上给你答案.现在在忙一个管理系统!!

对ASP、.NET、SQL情有独钟的情圣王子! 俺目标:睡觉睡到自然醒数钱数到手抽筋!
2005-11-23 15:18
a4620269
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-11-23
收藏
得分:0 

好的。非常感谢。


if I=pig and I drop off that I no dread boiled water scald end if
2005-11-23 15:19
阳光白雪
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:39
帖 子:2220
专家分:0
注 册:2005-11-18
收藏
得分:0 

if k<>1 then
response.write "<b>"+"<a href='index.asp?page=1'><font color=""#FFFFFF"">[首页]</font></a></b> "
response.write "<b>"+"<a href='index.asp?typeid="+typeid+"&page="+cstr(k-1)+"'><font color=""#FFFFFF"">[上一页]</font></a></b> "
else
Response.Write "<font color=""#FFFFFF"">[首页] [上一页]</font>"
end if
if k<>n then
response.write "<b>"+"<a href='index.asp?typeid="+typeid+"&page="+cstr(k+1)+"'><font color=""#FFFFFF"">[下一页]</font></a></b> "
response.write "<b>"+"<a href='index.asp?typeid="+typeid+"&page="+cstr(n)+"'><font color=""#FFFFFF"">[尾页]</font></a></b> "
else
Response.Write "<font color=""#FFFFFF"">[下一页] [尾页]</font>"


你看看你在跳转连接的时候确定正确吗?我看你跳转到了 index.asp页面中,是否此处出错了!

if typeid<>"b" and province<>"a" and keyword<>"" then
sql = "select * from goods where typeid='"&typeid&"'and name like '%"&keyword&"%' and province='"&province&"' and savetime>=date()-'"&wanttime&"'order by savetime desc"
elseif typeid="b" and province="a" and keyword="" and wanttime<>"" then
sql = "select * from goods where savetime>=date()-'"&wanttime&"'order by savetime desc"
elseif typeid="b" and province="a" and keyword<>"" then
sql = "select * from goods where name like '%"&keyword&"%' and savetime>=date()-'"&wanttime&"'order by savetime desc"
elseif typeid="b" and province<>"a" and keyword="" then
sql = "select * from goods where province='"&province&"'and savetime>=date()-'"&wanttime&"'order by savetime desc"
elseif typeid<>"b" and province="a" and keyword="" then
sql = "select * from goods where typeid='"&typeid&"'and savetime>=date()-'"&wanttime&"'order by savetime desc"
elseif typeid<>"b" and province<>"a" and keyword="" then
sql = "select * from goods where typeid='"&typeid&"'and province='"&province&"' and savetime>=date()-'"&wanttime&"'order by savetime desc"
elseif typeid<>"b" and province="a" and keyword<>"" then
sql = "select * from goods where typeid='"&typeid&"'and name like '%"&keyword&"%' and savetime>=date()-'"&wanttime&"'order by savetime desc"
elseif typeid="b" and province<>"a" and keyword<>"" then
sql = "select * from goods where province='"&province&"' and name like '%"&keyword&"%' and savetime>=date()-'"&wanttime&"'order by savetime desc"
end if

rs.open sql,conn,1,3

此外上面这段对参数程序补台灵活,很容易出现错无,例如,用户要求只查询typeid=b这一种情况,你的程序中就没有这中情况,而不会给sql赋值,这样系统就会提示下面错误:

Microsoft JET Database Engine 错误 '80040e07'

标准表达式中数据类型不匹配。

/asp4/search.asp,行 57

建议把查询条件用累加方式定义,下面有段SQL查询代码:
<%
Set lObj = CreateObject("ObjHCSystem.CAdo")
Set lObj.AdoConn = Session("sAdoConn").AdoConn
Page=Request.QueryString("Page")
dim batch_no,setupym,probrief_no,prod_item,suit_no,um_id,task_qty,adjust_qty,comp_flag,comp_status,comp_qty,complexion,enter_man,enter_date
if page="" then
page = 1
end if
batch_no = request.Form("batch_no")
setupym = request.Form("setupym")
probrief_no = request.Form("probrief_no")
prod_item = request.Form("prod_item")
suit_no = request.Form("suit_no")
um_id = request.Form("um_id")
task_qty = request.Form("task_qty")
adjust_qty = request.Form("adjust_qty")
comp_flag = request.Form("comp_flag")
comp_status = request.Form("comp_status")
comp_qty = request.Form("comp_qty")
complexion = request.Form("complexion")
enter_man = request.Form("enter_man")
enter_date = request.Form("enter_date")
Dim condition
condition="1=1"
If batch_no<>"" Then
condition=condition&" And batch_no Like '%"&batch_no&"%'"
End If
If setupym<>"" Then
condition=condition&" And setupym Like '%"&setupym&"%'"
End If
If probrief_no<>"" Then
condition=condition&" And probrief_no Like '%"&probrief_no&"%'"
End If
If prod_item<>"" Then
condition=condition&" And prod_item Like '%"&prod_item&"%'"
End If
If suit_no<>"" Then
condition=condition&" And suit_no Like '%"&suit_no&"%'"
End If
If um_id<>"" Then
condition=condition&" And um_id Like '%"&um_id&"%'"
End If
If task_qty<>"" Then
condition=condition&" And task_qty = '"&task_qty&"'"
End If
If adjust_qty<>"" Then
condition=condition&" And adjust_qty = '"&adjust_qty&"'"
End If
If comp_flag<>"" Then
condition=condition&" And comp_flag Like '%"&comp_flag&"%'"
End If
If comp_status<>"" Then
condition=condition&" And comp_status Like '%"&comp_status&"%'"
End If
If comp_qty<>"" Then
condition=condition&" And comp_qty = '"&comp_qty&"'"
End If
If complexion<>"" Then
condition=condition&" And complexion = '"&complexion&"'"
End If
set rssupp=lObj.selValue("d_setup_plan",""+condition+"","*")
%>

专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)
2005-11-23 16:23
a4620269
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-11-23
收藏
得分:0 
看不懂哦。

if I=pig and I drop off that I no dread boiled water scald end if
2005-11-23 20:06
rainic
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2367
专家分:0
注 册:2005-8-9
收藏
得分:0 

因为点击下一页时,那些用于查寻的参数都没了
楼主可以想办法把参数记下


2005-11-23 23:00
快速回复:请帮忙修复一下这段代码的BUG
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.083120 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved