ASP多重条件查询--在多个表中选择一个表查询

<!--#includefile="conn.asp"--><%dimmon,TeacherID,Coursemon=Request("month1")TeacherID... <!--#include file="conn.asp"-->
<%
dim mon,TeacherID,Course
mon=Request("month1")
TeacherID=Request("TeacherID")
Sex=Request("Sex")
Department=Request("Department")
if Request.Form("month1")="0" then
response.write "<script>alert('请选择要查询的月份!');history.back();</script>"
response.end
end if
%>
<table width="250" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="118" height="28"><div align="center">教师编号:</div></td>
<td width="126"><div align="center">本月课时:</div></td>
</tr>
<%
<%
Set rs = Server.CreateObject("ADODB.RecordSet")
sqls="select * from TInformation where 1=1"
sqls=sql("TeacherID",TeacherID,sqls)
sqls=sql("Sex",Sex,sqls)
sqls=sql("Department",Department,sqls)
sqls=sqls&" Order by Id"
rs.open sqls,conn,1,3
if rs.eof or rs.bof then
response.write "<script>alert('没有符合条件的记录!');history.back();</script>"
response.end
end if
'多条件连接函数
Function sql(a,b,sqls)
if b<>"" then
sqls=sqls&"and "&a&"='"&b&"'"
end if
sql=sqls
End Function
rs.pagesize=10
rCount=cint(rs.RecordCount/rs.pagesize)
curpage=Request.QueryString("curpage")
if curpage="" then curpage=1
rs.absolutepage=curpage
for i= 1 to rs.pagesize
if rs.eof then
exit for
end if
c=rs("TeacherID")
Set srs = Server.CreateObject("ADODB.RecordSet")
sql1 = "Select*from Course"&mon&"_time where TeacherID='"&c&"'"
srs.Open sql1,conn,1,3
%>
<tr>
<td height="27"><%=srs("TeacherID")%></td>
<td><%=srs("Course_time")%></td>
</tr>
<%
srs.close
Set srs=nothing
rs.movenext
next
%>
<tr align="center">
<td colspan="6">
<%Response.Write("共有"&Trim(rs.RecordCount)&"条用户记录")%>
<%if curpage=1 then%>
首页
<%else%>
<a href="chaxun.asp?TeacherID=<%=Request("TeacherID")%>&Sex=<%=Request("Sex")%>&Department=<%=Request("Department")%>&curpage=1">首页</a>
<%end if%>
<%if curpage=1 then%>
上一页
<%else%>
<a href="chaxun.asp?TeacherID=<%=Request("TeacherID")%>&Sex=<%=Request("Sex")%>&Department=<%=Request("Department")%>&curpage=<%=curpage-1%>">上一页</a>
<%end if%>
<%if rs.pagecount<curpage+1 then%>
下一页
<%else%>
<a href="chaxun.asp?TeacherID=<%=Request("TeacherID")%>&Sex=<%=Request("Sex")%>&Department=<%=Request("Department")%>&curpage=<%=curpage+1%>">下一页</a>
<%end if%>
<%if rs.pagecount<curpage+1 then%>
尾页
<%else%>
<a href="chaxun.asp?TeacherID=<%=Request("TeacherID")%>&Sex=<%=Request("Sex")%>&Department=<%=Request("Department")%>&curpage=<%=rs.pagecount%>">尾页</a>
<%end if%>
<%Response.Write "第"&curpage&"页 共"&Trim(rCount)&"页" %>
</td>
</tr>
</table>
补充:主要问题是sql1 = "Select*from Course"&mon&"_time where TeacherID='"&c&"'"语句中的这个语句,比如mon=1,那么我要查询的表是Course1_time,课时多重条件查询分页后,点击下一页时,查询的表就变成Course_time了,而不是Course1_time,因而点击下一页失败。请问各位高手,该如何解决此问题?
展开
 我来答
wohenhao1173
2009-03-25 · TA获得超过166个赞
知道小有建树答主
回答量:325
采纳率:100%
帮助的人:249万
展开全部
<a href="chaxun.asp?TeacherID=<%=Request("TeacherID")%>&Sex=<%=Request("Sex")%>&Department=<%=Request("Department")%>&curpage=<%=curpage+1%>">下一页</a>

你在这里面没有传递month1.加上month1=<%=mon%>
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式