<!--#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>
所有配套文件全在压缩包里,数据结构也在