查询页面的问题(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>