| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1775 人关注过本帖
标题:[求助]ASP多表查询问题
只看楼主 加入收藏
ml3300
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2006-4-16
结帖率:100%
收藏
 问题点数:0 回复次数:10 
[求助]ASP多表查询问题

图片附件: 游客没有浏览图片的权限,请 登录注册


图片附件: 游客没有浏览图片的权限,请 登录注册

数据库中有如上2张表,想做出如下的结果

图片附件: 游客没有浏览图片的权限,请 登录注册

此图代码
 </p>
<table width="71%" style="BORDER-COLLAPSE: collapse" borderColor=#808080 border="1" cellpadding="3" height="48" id="table2">
<tr bordercolor="#808080">
<td nowrap style="font-size: 12px"><font size="2">分班分数段:</font><input type="text" name="T1" id="T1" size="14"><font size="2">到<input type="text" name="T2" id="T2" size="14"></font><p>
<font size="2">每班人数:</font><input type="text" name="T3" id="T3" size="14"><p>

<%
set rs1=server.createobject("adodb.recordset")
sql1="select * from subject"
rs1.open sql1,conn,1,1
%>
<font size="2">课程名称</font>:<select size="1" name="kecm">
<%do while not rs1.eof%>
<option value="<%=rs1("课题名称")%>"><%=rs1("课题名称")%></option>
<%rs1.movenext%>
<%loop%>
<%rs1.close%>
</select></td>
</tr>
</table>
<p> </p>
<p>
<input type="submit" name="Submit" value="提交">
<input type="reset" name="Submit2" value="重置"><p>

图片附件: 游客没有浏览图片的权限,请 登录注册

此图代码写到这
<%
T1 = request.form("T1")
T2 = request.form("T2")
T3 = request.form("T3")
T4=trim(request("kecm"))
if T1 = "" then
conn.close
set conn = nothing
response.write "<script>alert('请输入起始分数');history.go(-1);</script>"
response.end
end if
if T2 = "" then
conn.close
set conn = nothing
response.write "<script>alert('请输入结束分数');history.go(-1);</script>"
response.end
end if
if T3 = "" then
conn.close
set conn = nothing
response.write "<script>alert('请输入每班级人数');history.go(-1);</script>"
response.end
end if

if T1 > T2 then
response.write "<script>alert('起始分数要低于结束分数');history.go(-1);</script>"
end if
%>
下面怎么写不下去了,说ODBC类型不支持,2表之间怎么联查呢?谢谢大家帮忙!


搜索更多相关主题的帖子: ASP 查询 
2007-05-07 00:52
ml3300
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2006-4-16
收藏
得分:0 

自己顶一个,大家帮忙啊,菜鸟问题。

2007-05-07 12:57
lq7350684
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5089
专家分:98
注 册:2006-11-6
收藏
得分:0 
分班分数段是什么意思?
还有下面判断T1为空的时候,晚上要关闭conn呢?
这两个表你想怎么联系说一下。
2007-05-07 14:03
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 

楼主图片里选题编号是一个名字的字段,这两个字段应该是有关联的吧?

2007-05-07 21:24
ml3300
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2006-4-16
收藏
得分:0 

之前问题在大家关怀下解决了,但现在有个新问题
<!--#include file="conn.asp"-->
<%
if session("user")="" then
response.write "您无此权限"
response.end
end if

%>

<%
T1 = trim(request("T1"))
T2 = trim(request("T2"))
T3 = trim(request("T3"))
T4=request.form("kecm")

if T1 = "" then
conn.close
set conn = nothing
response.write "<script>alert('请输入起始分数');history.go(-1);</script>"
response.end
end if
if T2 = "" then
conn.close
set conn = nothing
response.write "<script>alert('请输入结束分数');history.go(-1);</script>"
response.end
end if
if T3 = "" then
conn.close
set conn = nothing
response.write "<script>alert('请输入每班级人数');history.go(-1);</script>"
response.end
end if

if T1 > T2 then
response.write "<script>alert('起始分数要低于结束分数');history.go(-1);</script>"
response.end

end if
%>

<%dim cno
sqla = "select * from subject where 课题名称 ='"&T4&"'"
set aa = server.createobject("adodb.recordset")
aa.open sqla,conn,1,1
cno=aa("选题编号")

response.write cno
sql = "select * from student where xtbh = '"&cno&"'and student.cj between'"&T1&"' and '"&T2&"' order by 专业"
set rst = server.createobject("adodb.recordset")
rst.open sql,conn,1,1
%>
<html>
<head>

<title>分班结果</title>
<link rel="stylesheet" href="style.css">
</head>

<body topmargin="0">
<!--#include file="top.asp"-->
<%
if Not(rst.bof and rst.eof) then'判别数据表中是否为空记录
NumRecord=rst.recordcount
rst.pagesize=T3
NumPage=rst.Pagecount
if request("page")=empty then
NoncePage=1
else
if Cint(request("page"))<1 then
NoncePage=1
else
NoncePage=request("page")
end if
if Cint(Trim(request("page")))>Cint(NumPage) then NoncePage=NumPage
end if
else
NumRecord=0
NumPage=0
NoncePage=0
end if
%>

<div align="center">
<table width="760" height="35" cellspacing="0" cellpadding="0">
<td background="images/top_1.jpg">
<p align="center"> <b><font size="3">此为本课程</font><font size="5" color="#FF0000"><%=NoncePage%></font><font size="3">班学生名单</font></table>
</div>
<div align="center">
<center>
<table border="0" width="700" cellspacing="0" cellpadding="0">

<table border="1" width="760" bordercolorlight="#000000" cellspacing="1" cellpadding="5" bordercolordark="#FFFFFF" height="33">
<tr>

<td width="56" bgcolor="#EBE9FE" align="center" height="11">学号</td>
<td width="116" bgcolor="#EBE9FE" align="center" height="11">姓名</td>
<td width="118" bgcolor="#EBE9FE" align="center" height="11">专业</td>
<td width="249" bgcolor="#EBE9FE" align="center" height="11">所选课程</td>
<td width="77" bgcolor="#EBE9FE" align="center" height="11">联系方式</td>
<td width="76" bgcolor="#EBE9FE" align="center" height="11">成绩</td>
</tr>
<%if Not(rst.bof and rst.eof) then
rst.move (Cint(NoncePage)-1)*T3,1
for i=1 to rst.pagesize
%>

<tr>

<td width="56" align="center" height="1"><%=rst("学号")%></td>
<td width="116" align="center" height="1"><%=rst("姓名")%></td>
<td width="118" align="center" height="1"><%=rst("专业")%></a></td>
<td width="249" align="center" height="1"><%=T4%></td>
<td width="77" align="center" height="1"><%=rst("电话")%></a></td>
<td width="76" align="center" height="1"><%=rst("cj")%></td>
</tr>
<% rst.movenext
if rst.eof then exit for
next
else
response.write "<tr><td colspan=13><marquee scrolldelay=120 behavior=alternate>没有找到任何记录!!!</marquee></td></tr>"
end if

rst.close
set rst=nothing

%>

</table>
</table>
</div>
<div align="center">
<table width="760" border="0">
<tr>
<td height="17">

<div align="right">
<input type="hidden" name="page" value="<%=NoncePage%>">
<%
if NoncePage>1 then
response.write "|<a href=fenban1.asp?page=1&T1="&T1&"&T2="&T2&"&T3="&T3&"&T4="&T4&"'>首 页</a>| |<a href=fenban1.asp?page="&NoncePage-1&">上一页</a>|&nbsp"
else
response.write "|首 页| |上一页|&nbsp"
end if
if Cint(Trim(NoncePage))<Cint(Trim(NumPage)) then
response.write "|<a href=fenban1.asp?page="&NoncePage+1&">下一页</a>| |<a href=fenban1.asp?page="&NumPage&">尾 页</a>|"
else
response.write "|下一页| |尾 页|"
end if
%>
&nbsp;页次:<font color="#0033CC"><%=NoncePage%></font>/<font color="#0033CC"><%=NumPage%></font>
共<font color="#0033CC"><%=NumRecord%></font>条记录&nbsp; </div>
</td>

</table>
<%
aa.close
set aa=nothing

%>
</div>
</center>
<!--#include file="down.asp"-->
</body>

</html>

假如查询出来的人数多于设定的每班人数T3,就要分页,但在点下一页时,发现参数传不到下页去,有人说把response.write "|<a href=fenban1.asp?page=1>首 页</a>

改为:

response.write "|<a href='fenban1.asp?page=1&t1="&t1&"&t2="&t2&"&t3="&t3&"&t4="&t4&"'>首 页</a>
就能传过去,可我试验了一下,好像传过去了,但提示aa.open sqla,conn,1,1(打红色部分)BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。怎么解决呢?

[此贴子已经被作者于2007-5-7 22:06:39编辑过]

2007-05-07 21:56
ml3300
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2006-4-16
收藏
得分:0 
T1,T2,T3传过去了。T4是文字,没传过去,怎么才能传过去呢?
2007-05-08 08:44
lq7350684
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5089
专家分:98
注 册:2006-11-6
收藏
得分:0 
<%if Not(rst.bof and rst.eof) then
改为<%if Not(rst.bof or rst.eof) then
试试看.
2007-05-08 09:08
ml3300
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2006-4-16
收藏
得分:0 

lq7350684,你好,你的方法解决不了问题啊,现在的关键是T4没传过去呢!记录集里是空的。

2007-05-08 10:56
gdk2006
Rank: 4
等 级:业余侠客
威 望:8
帖 子:928
专家分:270
注 册:2006-7-2
收藏
得分:0 
自己先去想想先!!!

程序员的悲哀如何找女朋友?
追女解决方案百度“让她着迷”!
2007-05-08 11:46
lq7350684
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5089
专家分:98
注 册:2006-11-6
收藏
得分:0 

没传过去值,那你就要想想为什么没有传过去了.
把传值的几种方法都试一下.
基本用的就是:1.在链接后跟参数
2.用隐藏表单传值
如果还不行,那就要好好看看是不是传值的问题了.

2007-05-08 13:34
快速回复:[求助]ASP多表查询问题
数据加载中...
 
   



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

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