| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 561 人关注过本帖
标题:刚学asp,以下代码中诚求模糊查询与条件查询
只看楼主 加入收藏
linxingzhi
Rank: 1
等 级:新手上路
帖 子:4
专家分:7
注 册:2011-3-19
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
刚学asp,以下代码中诚求模糊查询与条件查询
初接触asp,以下添加什么代码来实现模糊查询和合同时间、所属分公司的查询,请高手看看还有哪里有错误的地方




<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel="stylesheet" href="css/css.css">
<title>办公系统</title>

<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>
</head>
<body bgcolor="#eeeeee" topmargin="5" leftmargin="5">
<%
call bghead()
%>


 


<center>
<table>
<tr>
<td><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;档案合同目录</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>


</tr>
</table>
</center>




<center>
</center>
<%
call bgmid()
%>





   <tr>
   
<td width="76%" align="right">
 合同查询:
    <%
    sql="select * from newnoticed order by id"
    set rs_newnoticed=conn.execute(sql)
    %>
      <select name="newnoticed" onChange="form2.submit()">
        <option value="">所有分公司</option>
        <%
    do while rs_suoshugongsi.eof=false
    %>
        <option value="<%=rs_suoshugongsi("id")%>"<%if trim(cstr(rs_suoshugongsi("id")))=nowsuoshugongsi then%> selected="selected"<%end if%>><%=rs_suoshugongsi("suoshugongsi")%></option>
        <%
      rs_ku.movenext
    loop
    %>
      </select>      
    <%
    sql="select * from hetongshijian order by id"
    set rs_hetongshijian=conn.execute(sql)
    %>
      <select name="hetongshijian" onChange="form2.submit()">
        <option value="">所有时间</option>
        <%
    do while rs_hetongshijian.eof=false
    %>
        <option value="<%=rs_hetongshijian("id")%>"<%if trim(cstr(rs_hetongshijian("id")))=nowhetongshijian then%> selected="selected"<%end if%>><%=rs_hetongshijian("hetongshijian")%></option>
        <%
      rs_hetongshijian.movenext
    loop
    %>
      </select>
   
      <input type="text" name="keyword" size="20" value="<%=nowkeyword%>">
      <input type="submit" value=" 查询 ">



<center>

<%
set conn=opendb("oabusy","conn","accessdsn")
Set rs=Server.CreateObject("ADODB.recordset")
sql="select * from newnoticed order by id desc"
'if request("lookfor")="yes" then sql="select * from newnoticed where hetongshijian between " & "#" & hetongshijian & "# and #" & hetongshijian1 & "# order by id desc"
if request("lookfor")="yes" then sql="select * from newnoticed where hetongshijian between "  & hetongshijian & " and " & hetongshijian1 & " order by id desc"
rs.open sql,conn,1
if not rs.eof and not rs.bof then
rs.pagesize=20
page=clng(request("page"))
if page<1 then page=1
if page>rs.pagecount then page=rs.pagecount
href="noticelookd.asp"
rs.absolutepage=page
%>
<br>
<form method="post" action="<%=href%>?page=<%=page%>">
<table border="1" cellpadding="0" cellspacing="0" width="1033">
<tr>
    <td width="60" height="31" align=center><b>所属公司</b></td>
    <td width="59" align=center><b>合同名称</b></td>
    <td width="69" align=center><b>附件</b></td>
    <td width="59" align=center><b>建档日期</b></td>
    <td width="61" align=center><b>合同编号</b></td>
    <td width="61" align=center><b>甲方单位</b></td>
    <td width="87" align=center><b>乙方单位</b></td>
    <td width="77" align=center><b>服务项目</b></td>
    <td width="64" align=center><b>地点/面积</b></td>
    <td width="53" align=center><b>合同金额</b></td>
    <td width="54" align=center><b>收/付</b></td>
    <td width="69" align=center><b>合同起止期</b></td>
    <td width="54" align=center><b>合同状态</b></td>
    <td width="78" align=center><b>收/付日期</b></td>
    <td width="96" align=center><b>备注</b></td>
</tr>
<%
for ipage=1 to rs.pagesize
%>
<tr>
<td align="center" width=60><%=rs("suoshugongsi")%></td>
<td align="center" width=59><%=rs("title")%></td>
<td align="center">
<%
if rs("filename")<>"" then
%>
<a href="listnoticefile.asp?id=<%=rs("id")%>" target="_blank"><img src="images/attach.gif" width=30 height=30 border=0 alt="文件名:<%=rs("filename")%>"></a>
<%
else
%>
&nbsp;
<%
end if
%>
</td>
<td align="center" width=59><%=rs("noticedate")%></td>
<td align="center" width=61><%=rs("hetongpianhao")%></td>
<td align="center" width=61><%=rs("jiafangdanwei")%></td>
<td align="center" width=87><%=rs("yifangdanwei")%></td>
<td align="center" width=77><%=rs("fuwuxianmu")%></td>
<td align="center" width=64><%=rs("didianmianji")%></td>
<td align="center" width=53><%=rs("hetongjinge")%></td>
<td align="center" width=54><%=rs("shoufu")%></td>
<td align="center" width=69><%=rs("hetongshijian")%></td>
<td align="center" width=54><%=rs("hetongzhantai")%></td>
<td align="center" width=78><%=rs("shoufuriqing")%></td>
<td align="center" width=96><%=rs("beizhu")%></td>






</tr>
<%
rs.movenext
if rs.eof then exit for
next
%>
</table>
<input type="hidden" name="myyear" value="<%=myyear%>">
<input type="hidden" name="mymonth" value="<%=mymonth%>">
<input type="hidden" name="lookfor" value="<%=request("lookfor")%>">
<input type="hidden" name="page" value="<%=page%>">
</form>
<table border=0 width=550>
<tr><form action=<%=href%> method=get>
<td align="center">
<%
response.write "<a href=" & href & "?page=1&myyear=" & server.urlencode(myyear) & "&mymonth=" &  server.urlencode(mymonth) & "&lookfor=" & server.urlencode(request("lookfor")) & ">第一页</a>"
%>
</td>
<td align="center">
<%
response.write "<a href=" & href & "?page=" & (page-1) & "&myyear=" & server.urlencode(myyear) & "&mymonth=" &  server.urlencode(mymonth) & "&lookfor=" & server.urlencode(request("lookfor")) & ">上一页</a>"
%>
</td>
<td align="center">
<%
response.write "<a href=" & href & "?page=" & (page+1) & "&myyear=" & server.urlencode(myyear) & "&mymonth=" &  server.urlencode(mymonth) & "&lookfor=" & server.urlencode(request("lookfor")) & ">下一页</a>"
%>
</td>
<td align="center">
<%
response.write "<a href=" & href & "?page=" & rs.pagecount & "&myyear=" & server.urlencode(myyear) & "&mymonth=" &  server.urlencode(mymonth) & "&lookfor=" & server.urlencode(request("lookfor")) & ">最后一页</a>"
%>
</td>
<td align="center">
去第<input type=text name=page size=3>页</td>
<input type="hidden" name="myyear" value="<%=myyear%>">
<input type="hidden" name="mymonth" value="<%=mymonth%>">
<input type="hidden" name="lookfor" value="<%=request("lookfor")%>">
<td align="center">第<%=page%>/<%=rs.pagecount%>页</td></form></tr></table><br>



<%
else
%>
<br><br><br>
<table border="0" cellpadding="0" cellspacing="0" width="400">
<tr>
<td width="400" align="center"><font size="4" color="red">对不起,没有相关纪录</font></td></tr></table>
<%
end if
%>


</center>
<%
call bgback()
%>
</body>
</html>
搜索更多相关主题的帖子: Microsoft content 分公司 style link 
2011-05-13 08:52
linxingzhi
Rank: 1
等 级:新手上路
帖 子:4
专家分:7
注 册:2011-3-19
收藏
得分:0 
希望有高人指点一下。
2011-05-13 09:52
kangli_kl
Rank: 6Rank: 6
等 级:侠之大者
威 望:2
帖 子:134
专家分:489
注 册:2008-4-5
收藏
得分:10 
username123 = request.form("username")
精确查询:select * from table where username like '"&username123&"'
模糊查询:select * from table where username like '%"&username123&"%'

精确查询和模糊查询的关键在多字符通配符 %

求上而得中,求中而得下。
2011-05-13 10:32
liang198207
Rank: 5Rank: 5
等 级:职业侠客
帖 子:70
专家分:300
注 册:2011-5-10
收藏
得分:10 
精确好说,模糊的话那需要考虑的不少,单单用一个like恐怕实现不了!
2011-05-14 23:14
快速回复:刚学asp,以下代码中诚求模糊查询与条件查询
数据加载中...
 
   



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

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