| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 809 人关注过本帖
标题:查询页面的问题(ASP+SQL)
只看楼主 加入收藏
月夜NO风
Rank: 1
等 级:新手上路
帖 子:93
专家分:0
注 册:2008-6-29
结帖率:100%
收藏
 问题点数:0 回复次数:5 
查询页面的问题(ASP+SQL)
代码如下 :
功能就是查询订单,现在有几个问题想请教:
1.不想一进入此界面,就有结果,因为到时还要做每个用户只能看自己的订单.
2.用日期查询时,只能查到年,日期格式是"2008-01-01"这样的,但是如果输入"2008-01"就没有结果出来.
先谢谢各位了!
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#INCLUDE FILE="adovbs.inc"-->
<!--#INCLUDE FILE="dbtest_Conn.asp"-->
<html>
<% sId=Trim(Request.Form("txtsId")) %>
<% if session("sId")=""   then %>
  <% Response.Redirect("login.asp") %>
   <% else %>
   <% Response.Write("Welcome to XXX Industries Ltd.!")  %>
   <% end if  %>

<%
dim SqlConn,SqlRecSet
dim StrSQL
dim PurBn,PurBd,PurBs,PurBc,PurSr,PurRq,PurBrd,PurIn
%>
<%
Function genSQLstr()
    if Request.Form("PurBn")<>"" then
    StrSQL=StrSQL+"where sBillNo like '%"+Request.Form("PurBn")+"%'"
    else
    StrSQL=StrSql+"where sBillNo like '%'"
    end if
    if Request.Form("PurBd")<>"" then
    StrSQL=StrSQL+"and dBillDay like '%"+Request.Form("PurBd")+"%'"
    end if
    if Request.Form("PurSr")<>"" then
    StrSQL=StrSQL+"and sSuppId like '%"+Request.Form("PurSr")+"%'"
    end if
    if Request.Form("PurBrd")<>"" then
    StrSQL=StrSQL+"and dRecDate like '%"+Request.Form("PurBrd")+"%'"
    end if
End function
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>订单查询</title>
</head>
<body>
<div align="center">
<%
OpenConn()
Set SqlRecSet=Server.CreateObject ("ADODB.RECORDSET")
genSQLstr()
StrSQL="select * from pur_order "+StrSQL
SqlRecSet.Open StrSQL,SqlConn,adOpenForwardOnly,adLockReadOnly
%>
<span class="pagenote1">订单查询</span>
</div>
<hr>
<form name="PurForm" method="post">
<table width="566" align="center">
<tr>
<td width="558" bordercolor="#000000" bgcolor="#99CCCC">
<p>订单号:
  <input name="PurBn" type="text" size=20>
  订单日期 :
  <input name="PurBd" type="text" size=16>
  </p>
<p>交货日期:
  <input name="PurBrd" type="text" size=16>
  供应商:
  <input name="PurSr" type="text" size=16>
</p>
<center><input name="PurUp" value="查询" type="submit"></center>
</table>
</form>
<div align="center">
<table width="731" border="1" align="center"
 cellspacing="0" bordercolor="#000000"
bordercolorlight="#000000" bordercolordark="#FFFFFF">
  <tr class="tableth1"><td height="22" width="725"><table width="742" border="1" align="center"
 cellspacing="0" bordercolor="#000000"
bordercolorlight="#000000" bordercolordark="#FFFFFF">
  <tr class="tableth1">
    <td height="22" width="119">订单号</td>
    <td height="22" width="88">订单日期</td>
    <td height="22" width="73">物料数量</td>
    <td height="22" width="96">物料编码</td>
    <td height="22" width="72">物料名称</td>
    <td height="22" width="44">供应商</td>
    <td height="22" width="97">交货日期</td>
    <td height="22" width="119">已收数量</td>
  </tr>
  <%
while not SqlRecSet.EOF
    PurBn=SqlRecSet.Fields("sBillNo").value
    PurBd=SqlRecSet.Fields("dBillDay").value
    Purbs=SqlRecSet.Fields("fQty").value
    PurBc=SqlRecSet.Fields("sItemId").value
    PurIn=SqlRecSet.Fields("sItemId_Name").value
    PurSr=SqlRecSet.Fields("sSuppId").value
    PurRq=SqlRecSet.Fields("fRecQty").value
    PurBrd=SqlRecSet.Fields("dRecDate").value
%>
    <td><%=PurBn%></td>
    <td><%=PurBd%></td>
    <td><%=PurBs%></td>
    <td><%=PurBc%></td>
    <td><%=PurIn%></td>
    <td><%=PurSr%></td>
    <td><%=PurBrd%></td>
    <td><%=PurRq%></td>
  </tr>
  <%
    SqlRecSet.MoveNext
wend
SqlRecSet.Close
SqlConn.Close
%>
</table></td>
</tr>
</table>
</body>
</html>
搜索更多相关主题的帖子: SQL ASP 页面 查询 
2008-07-15 12:13
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
收藏
得分:0 
1.写个判断,判断查询内容是否为空,如果为空就不显示,不为空就执行查询语句
2.使用模糊查询来查询日期 riqi like '%"&Request.Form("riqi")&"%'

[编程论坛] ASP超级群:49158383  敲门暗号:ASP编程
龍艺博客 http://www.
2008-07-15 12:28
月夜NO风
Rank: 1
等 级:新手上路
帖 子:93
专家分:0
注 册:2008-6-29
收藏
得分:0 
谢谢版主给我个思路,我想想看应该怎么写先.
2008-07-15 12:30
月夜NO风
Rank: 1
等 级:新手上路
帖 子:93
专家分:0
注 册:2008-6-29
收藏
得分:0 
<% if Request.Form("PurBn")="" and Request.Form("PurBd")="" and Request.Form("PurSr")=""
  and Request.Form("PurBrd")=""
  Then response.Redirect("pur_list")
  else  response.Write("请填入要查询的内容!")
  end if
  %>
提示:
技术信息(用于支持人员)

错误类型:
Microsoft VBScript 编译器错误 (0x800A03F9)
缺少 'Then'
/pur_list.asp, line 85, column 85
if Request.Form("PurBn")="" and Request.Form("PurBd")="" and Request.Form("PurSr")=""
------------------------------------------------------------------------------------^
2008-07-15 15:11
madpbpl
Rank: 4
等 级:贵宾
威 望:11
帖 子:2876
专家分:244
注 册:2007-4-5
收藏
得分:0 
if Request.Form("PurBn")="" and Request.Form("PurBd")="" and Request.Form("PurSr")=""
  and Request.Form("PurBrd")=""
  Then
以上内容写在一行

如果以下内容写在一行,请在Then和后面的内容中间加“:”
if Request.Form("PurBn")="" and Request.Form("PurBd")="" and Request.Form("PurSr")=""
  and Request.Form("PurBrd")=""
  Then response.Redirect("pur_list")
2008-07-15 17:30
月夜NO风
Rank: 1
等 级:新手上路
帖 子:93
专家分:0
注 册:2008-6-29
收藏
得分:0 
<%if Request.Form("PurBn")="" and Request.Form("PurBd")="" and Request.Form("PurSr")="" and Request.Form("PurBrd")=""  Then %>
  
<% response.Redirect("pur_list.asp")  %>
 <%  response.Write("请输入最少一个查询条件!谢谢!") %>
 <% End if %>
就算我写成上面这样也还是提示没有THEN.........
2008-07-16 08:54
快速回复:查询页面的问题(ASP+SQL)
数据加载中...
 
   



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

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