蓝森林首页 | 返回主页 | 本站地图 | 站内搜索 | 联系信箱 |
 您目前的位置:首页 > 自由软件 > 技术交流 > 应用编程


    

蓝森林 http://www.lslnet.com 2006年8月25日 8:28

[Asp]关于查询的问题

我用ASP做了一个查询。可是无论查询条件是什么。查询的结果都是一样的。大家帮看看是哪里出现问题
代码如下:
[teacher.asp]
<table width="560" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
<form name="form1" method="POST" action="searchteacher.asp">
<tr><td>
<table width="560" height="25" border="0" cellpadding="0" cellspacing="0" class="table">
      <tr>
        <td align="center">
            <font color="#000080">范围:</font>
            <select name="D1" size="1">
              <option value="object">家教科目</option>
              <option value="pay" selected>期望报酬</option>
            </select>
            <font color="#000080">查找关键字:</font> <font color="#000080">
            <input type="text" name="searchcontent" size="20">
            </font> <font color="#000080">
            &nbsp;</font>
            <input type="submit" value="查询"  name="search" >
        </td>
      </tr>
    </table>
</form>
</td></tr>
</table>
[searchteacher.asp]
<%
  searchcontent1 = Request("searchcontent")
  fanwei = Request("fanwei")
  searchcontent = "%" & searchcontent1 & "%"
  ' 取得查询范围值
  searchfanwei = Request("D1")
  If searchfanwei="object" Then
        Response.Write "<h4><font color=#7966C6>教员查询结果[按科目]</font></h4><br>"
        strSQL = " object LIKE '" & searchcontent & "' ORDER BY ID DESC"
  ElseIf searchfanwei="pay" Then  
        Response.Write "<h4><font color=#7966C6>教员查询结果[按报酬]</font></h4><br>"
        strSQL = "pay LIKE '" & searchcontent1 & "' ORDER BY ID DESC"
  End If
  '合并查询条件
  If Len(strSqlPTime)=0 Then
        strSQL = " WHERE " & strSQL
  Else
        strSQL = strSqlPTime & " And " & strSQL
  End If
%>
<table width="460" align="center" class="table" aglin="center">
<tr bgcolor="#33CCFF">
<td width="30" height="20" align=center><b>序号</b></td>
<td width="100" align=center><b>姓名</b></td>
<td width="30" align=center><b>性别</b></td>
<td width="100" align=center><b>家教科目</b></td>
<td width="100" align=center><b>期望报酬</b></td>
<td width="100" align=center><b>授课时间</b></td>
</tr>
<%       
  Dim rsSearch,Tnumber
  Tnumber=0
  Set rsSearch= Server.CreateObject("ADODB.RecordSet")
  strSQL = "SELECT * FROM teacher "
  rsSearch.Open strSQL, Conn, 1,3
  Do While Not rsSearch.EOF
  Tnumber = Tnumber + 1
%>
    <tr bgColor=Lavender style='COLOR:purple;'>
    <td height="20" align=middle><div align="center"><%=Tnumber%></div></td>
    <td><div align="center"><a href=teacherView.asp?id=<%=rsSearch("Id")%>><%=rsSearch("Tname")%></a></div></td>
        <td><div align="center"><%=rsSearch("Sex")%></div></td>
        <td><div align="center"><%=rsSearch("object")%></a></div></td>
        <td><div align="center"><%=rsSearch("pay")%></a></div></td>
        <td><div align="center"><%=rsSearch("time")%></a></div></td>
<%
  rsSearch.MoveNext()
  LOOP
%>
</table>
<%
  Set rsSearch = Nothing
  Set Conn = Nothing
%>
</body>




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 蓝森林网站 版权所有。 E-mail : webmaster@lslnet.com