| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 585 人关注过本帖
标题:[求助]大哥大姐,我都熬四天夜了,就是找不到原因
只看楼主 加入收藏
tzfzjt
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-1-2
收藏
 问题点数:0 回复次数:5 
[求助]大哥大姐,我都熬四天夜了,就是找不到原因
hBrIVz7d.rar (107.22 KB) [求助]大哥大姐,我都熬四天夜了,就是找不到原因




<!--#include file="data.asp"-->
<%
port1=trim(request.form("port1"))'接收查询始发站关键字
port2=trim(request.form("port2"))'接收查询终点站关键字
opt=trim(request.form("opt"))'接收查询列车规格关键字
select case opt '组织sql语句
case "特快"
sql1="select * from detail where port ='"&port1&"'and train_type='"&"空调特快"&"' order by id asc"
case "空调快速"
sql1="select * from detail where port ='"&port1&"'and train_type='"&"空调快速"&"' order by id asc"
case "CRH"
sql1="select * from detail where port ='"&port1&"'and train_type='"&"CRH"&"' order by id asc"
case "普快"
sql1="select * from detail where port ='"&port1&"'and train_type='"&"普快"&"' order by id asc"
case "其他"
sql1="select * from detail where port ='"&port1&"'"
end select
set rs1=server.createobject("adodb.recordset")
rs1.open sql1,con,1,3
If Rs1.Eof Then
output="没有查询到经过"&port1&"和"&port2&"的"&opt&"列车,可能您输入有误,也可能管理员数据没有录入!"
msg(output)
end if
Dim RsArr
RsArr=Rs1.GetRows(-1) '将rs1记录集返回的对象保存到数组里
rs1.close
set rs1=nothing
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>经过<%=port1%>和<%=port2%>的火车信息</title>
<head>
<style type="text/css">
<!--
BODY {
SCROLLBAR-FACE-COLOR: #FFFFFF;
SCROLLBAR-HIGHLIGHT-COLOR: #52D0E5;
SCROLLBAR-SHADOW-COLOR: #52D0E5;
SCROLLBAR-3DLIGHT-COLOR: #FFFFFF;
SCROLLBAR-ARROW-COLOR: #52D0E5;
SCROLLBAR-TRACK-COLOR: #88e8f8;
SCROLLBAR-DARKSHADOW-COLOR: #FFFFFF;
}
a:link {
color:#003300;
text-decoration: none;
}
a:visited {
color:#003300;
text-decoration: none;
}
a:hover {
color: #0099FF;
text-decoration: none;
position:relative;
left:1px;
top:1px;
}
a:active {
color: #0099FF;
text-decoration: none;
}
td{
color:blue;
font-family:"宋体";
font-size:9pt;
}
fieldset {
position:absolute;
left:100px;
top:10px;
width:850px;
height:500px;
padding:10px;
margin-top:5px;
border:1px solid deepskyblue;
background:#f9f9f9;
text-align:center;
background-image:url("image\flower.jpg");
background-repeat:no-repeat;
background-position: center;
text-align:center;
filter:alpha(opacity=50);
}
#search{
position:absolute;
left:80px;
top:35px;
width:700px;
}
fieldset legend {
font-family: "宋体";
font-size: 9pt;
color:#888888;
font-weight:solid;
padding:3px 20px 3px 20px;
border:1px solid deepskyblue;
background:#f9f9f9;
}
-->
</style>
</head>
<body bgcolor=#f9f9f9>
<fieldset>
<legend><a href="index.asp" target="_self">火车查询</a>→ 站站查询结果</legend>
<div id=search>
<table border=1 cellspacing=0 cellpadding=0 bordercolordark=#ffffff bordercolorlight=#e8e8e8>
<tr>
<td align=center width=100>车次</td>
<td align=center width=100>车型</td>
<td align=center width=100>始发站</td>
<td align=center width=100>终点站</td>
<td align=center width=100>发车时间</td>
<td align=center width=100>到站时间</td>
<td align=center width=100>历时</td>
</tr>
<%
For i=0 To Ubound(RsArr,2) '遍历记录行
set rs2=server.createobject("adodb.recordset")
sql2="select * from detail where port ='"&port2&"'and train_id='"&RsArr(1,i)&"'"'这里1表示表里的第二列,即车次-train_id
rs2.open sql2,con,1,3
a=rs2("train_id")
sql3="select * from train where train_id in('"&RsArr(1,i)&"')"'我是想查询经过两个车站的火车,我有三个表,具体见数据库,我先取得经过port1的火车的
'车次号,这里面肯定有不经过port2的,所以又来了一次对表detail的查询,并附加条件RsArr(1,i)『表示经过port1的车次』,通过二次查询得到经过port1和port2的火车车次,
'这里用了一个循环For i=0 To Ubound(RsArr,2),大哥大姐们,问题在后面啊!
sql3="select * from train where train_id='"&rs2("train_id")&"'"'我这里的意思是:train里保存的是某一火车始发站和终点站的消息,我本意是在得到经过port1和port2的火车车次后,再根据车次
'再对train表进行查询,欲在此页一起显示经过两个站火车的到/离站时间(在detail表),始发(终点)站,路程,发车/到终点站时间(在train表里)
'问题就出在sql3里,当你查询南京到上海的所有列车时,程序正常,当你查询芜湖到上海的所有列车时报错,错 误 码:0x80020009,错误代码:sql3="select * from train where train_id='"&rs2("train_id")&"'"'
'文件名称:c:\documents and settings\sicent\桌面\site\port_port.asp,所在行号:126,我都郁闷死了,我找不出原因
'我的问题是一报错原因,二,在这个for next为什么不能给变量赋值(a=rs2("train_id"),他报错说a=rs2("train_id")错误,BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。我就纳闷此时怎会是eof orbof呢?)
'三,这里不能设置分页,因为符合条件数据很多,一分他就说循环控制变量for无效??????大哥大姐们,你们帮帮我吧,我都熬了几个通宵都美啃下来,谁能帮我解决问题,拿真是感激涕零啊,我又多少分全给你们!谢谢啊!
set rs3=server.createobject("adodb.recordset")
rs3.Open sql3,con,1,3
%>
<tr>
<td align=center width=100><%=rs2("train_id")%></td>
<td align=center width=100><a href="detail.asp?id=<%=rs2("train_id")%>"><%=rs2("train_type")%></a></td>
<td align=center width=100><%=rs3("start_port")%></td>
<td align=center width=100><%=rs3("destination")%></td>
<td align=center width=100><%=rs3("arrive_time")%></td>
<td align=center width=100><%=rs3("left_time")%></td>
<td align=center width=100><%=rs3("time_long")%></td>
</tr>
<%
next
rs3.close
set rs3=nothing
rs2.close
set rs2=nothing
con.close
set con=nothing
%>
</table>
</div>

</fieldset>
</form>
</body>
</html>
所有配套文件全在压缩包里,数据结构也在
搜索更多相关主题的帖子: 大姐 
2007-06-18 07:31
SkyGull
Rank: 5Rank: 5
来 自:浙江杭州
等 级:贵宾
威 望:13
帖 子:839
专家分:324
注 册:2007-6-7
收藏
得分:0 
把错误列出来嘛...
2007-06-18 10:50
guyer
Rank: 2
等 级:新手上路
威 望:5
帖 子:451
专家分:0
注 册:2007-1-19
收藏
得分:0 

For i=0 To Ubound(RsArr,2) '遍历记录行
set rs2=server.createobject("adodb.recordset")
sql2="select * from detail where port ='"&port2&"'and train_id='"&RsArr(1,i)&"'"'这里1表示表里的第二列,即车次-train_id
rs2.open sql2,con,1,3
if not rs2.bof and not rs2.bof then '加个判断试试
a=rs2("train_id")
sql3="select * from train where train_id in('"&RsArr(1,i)&"')"'我是想查询经过两个车站的火车,我有三个表,具体见数据库,我先取得经过port1的火车的
'车次号,这里面肯定有不经过port2的,所以又来了一次对表detail的查询,并附加条件RsArr(1,i)『表示经过port1的车次』,通过二次查询得到经过port1和port2的火车车次,
'这里用了一个循环For i=0 To Ubound(RsArr,2),大哥大姐们,问题在后面啊!
sql3="select * from train where train_id='"&rs2("train_id")&"'"'我这里的意思是:train里保存的是某一火车始发站和终点站的消息,我本意是在得到经过port1和port2的火车车次后,再根据车次
'再对train表进行查询,欲在此页一起显示经过两个站火车的到/离站时间(在detail表),始发(终点)站,路程,发车/到终点站时间(在train表里)
'问题就出在sql3里,当你查询南京到上海的所有列车时,程序正常,当你查询芜湖到上海的所有列车时报错,错 误 码:0x80020009,错误代码:sql3="select * from train where train_id='"&rs2("train_id")&"'"'
'文件名称:c:\documents and settings\sicent\桌面\site\port_port.asp,所在行号:126,我都郁闷死了,我找不出原因
'我的问题是一报错原因,二,在这个for next为什么不能给变量赋值(a=rs2("train_id"),他报错说a=rs2("train_id")错误,BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。我就纳闷此时怎会是eof orbof呢?)
'三,这里不能设置分页,因为符合条件数据很多,一分他就说循环控制变量for无效??????大哥大姐们,你们帮帮我吧,我都熬了几个通宵豆美啃下来,谁能帮我解决问题,拿真是感激涕零啊,我又多少分全给你们!谢谢啊!
set rs3=server.createobject("adodb.recordset")
rs3.Open sql3,con,1,3
%>
<tr>
<td align=center width=100><%=rs2("train_id")%></td>
<td align=center width=100><a href="detail.asp?id=<%=rs2("train_id")%>"><%=rs2("train_type")%></a></td>
<td align=center width=100><%=rs3("start_port")%></td>
<td align=center width=100><%=rs3("destination")%></td>
<td align=center width=100><%=rs3("arrive_time")%></td>
<td align=center width=100><%=rs3("left_time")%></td>
<td align=center width=100><%=rs3("time_long")%></td>
</tr>

<% end if
next

rs3.close
set rs3=nothing

rs2.close
set rs2=nothing
con.close
set con=nothing
%>
</table>
</div>

</fieldset>
</form>
</body>
</html>


http://www./
2007-06-18 13:34
guyer
Rank: 2
等 级:新手上路
威 望:5
帖 子:451
专家分:0
注 册:2007-1-19
收藏
得分:0 

因为你在 For i=0 To Ubound(RsArr,2) '遍历记录行 的时候

你查询出来的记录肯定比遍历记录要少,但你没有判断数据库查询是否以为空, 所以会出错.


http://www./
2007-06-18 13:37
tzfzjt
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-1-2
收藏
得分:0 
回复:(guyer)因为你在 For i=0 To Ubound(R...
您好版主,我现在头都快炸了,比如我查芜湖到上海(数据库里肯定有记录)就会报错,说什么eof,具体演示在http://web610233.goofar.net/train
而查询南京到上海就不会报错,这我就纳闷了,麻烦版主好事做到底,帮我修改下,文件已经打包了,我这里谢谢了
2007-06-18 19:47
guyer
Rank: 2
等 级:新手上路
威 望:5
帖 子:451
专家分:0
注 册:2007-1-19
收藏
得分:0 
PoaK55Ka.rar (107.27 KB) [求助]大哥大姐,我都熬四天夜了,就是找不到原因




y1vlR6jl.gif (12.42 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册

http://www./
2007-06-19 13:29
快速回复:[求助]大哥大姐,我都熬四天夜了,就是找不到原因
数据加载中...
 
   



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

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