[bo][un]dhdhzzw[/un] 在 2008-7-23 17:46 的发言:[/bo]
不是跟你说过了么?到现在还在问。。。。。。。。。。
杀了你。。。。。。别说你不能用,我一直这么写一直在用。,除非你哪里错了没说清楚。,,,。
StrSQL=select * from table where dBillDay between '"&forma ...
错误类型:
Microsoft VBScript 运行时错误 (0x800A000D)
类型不匹配: 'format'
我数据库的日期格式是“2006-12-27”这样子的啊。
DATETIME,长度8.。。。
StrSQL=StrSQL+"and dBillDay between '"&format(Request.Form("PurDAY1"),"YYYY-DD-MM ")&"' and '"&format(Request.Form("PurDAY2"),"YYYY-DD-MM")&"'"
全部代码是这样的:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#INCLUDE FILE="adovbs.inc"-->
<!--#INCLUDE FILE="dbtest_Conn.asp"-->
<html>
<% sId=Trim(Request.Form("txtsID"))
' 注意这里sId一般没有值,因为pur_list.asp是直接访问没有Post的数据。
%>
<% If session("sId")=""
then %>
<% Response.Redirect("login.asp") %>
<% else %>
<% Response.Write("Welcome to Source Pro Industries Ltd.!")
%>
<% end if
%>
<%
dim SqlConn,SqlRecSet
dim StrSQL
dim PurBn,PurBd,PurBs,PurBc,PurSr,PurRq,PurBrd,PurIn,PurBd2,PurBitPurDAY,PurDAY2
%>
<%
Function genSQLstr()
Dim sId
sId=session("sId")
if Request.Form("PurBn")<>"" then
StrSQL=StrSQL+"where sBillNo like '%"+Request.Form("PurBn")+"%'"
else
StrSQL=StrSQL+"where sSuppId='"& sId &"'"
end if
if Request.Form("PurBdY")<>"" or Request.Form("PurBdM")<>"" or Request.Form("PurBdD")<>""
then
StrSQL=StrSQL+"and year(dBillDay)= '"& Request.Form("PurBdY")& "' and month(dBillDay)='"& Request.Form("PurBdM")& "' and day(dBillDay)='"& Request.Form("PurBdD")& "' "
end if
if Request.Form("PurBrdY")<>"" or Request.Form("PurBrdM")<>"" or Request.Form("PurBrdD")<>""
then
StrSQL=StrSQL+"and year(dRecDate)= '"& Request.Form("PurBrdY")& "' and month(dRecDate)='"& Request.Form("PurBrdM")& "' and day(dRecDate)='"& Request.Form("PurBrdD")& "' "
end if
if Request.Form("PurDAY1")<>"" and Request.Form("PurDAY2")<>"" then
StrSQL=StrSQL+"and dBillDay between '"&format(Request.Form("PurDAY1"),"YYYY-DD-MM ")&"' and '"&format(Request.Form("PurDAY2"),"YYYY-DD-MM")&"'"
end if
if Request.Form("PurBit")<>"" then
StrSQL=StrSQL+"and sItemId like '%"+Request.Form("PurBit")+"%'"
end if
' 只获取到自己的订单
strSQL=strSQL & " and sSuppId='" & Replace(sId,"'","''") & "'" ' 防止注入攻击
End function
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>订单查询</title>
</head>
<body>
<%
OpenConn()
Set SqlRecSet=Server.CreateObject("ADODB.RECORDSET")
genSQLstr()
SqlRecSet.CursorType=adOpenStatic
StrSQL="select * from pur_order "+StrSQL
SqlRecSet.Open StrSQL,SqlConn,adLockReadOnly
%>
<div align="center">
<span class="pagenote1">订单查询</span>
</div>
<hr>
<form name="PurForm" method="post" >
<table width="663" align="center">
<tr>
<td width="655" bordercolor="#000000" bgcolor="#99CCCC">
<p>订单号码:
<input name="PurBn" type="text" size=16>
订单日期 :
<input name="PurBdY" type="text" size=8>
年
<input name="PurBdM" type="text" size=8>
月
<input name="PurBdD" type="text" size=8>
日</p>
<p>物料编码:
<input name="PurBit" type="text" size=16>
交货日期 :
<input name="PurBrdY" type="text" size=8>
年
<input name="PurBrdM" type="text" size=8>
月
<input name="PurBrdD" type="text" size=8>
日</p>
订单日期从:
<input name="PurDAY1" type="text" size=16>
到:<input name="PurDAY2" type="text" size=16>
<p> </p>
</p>
<center><input name="PurUp" value="查询" type="submit" ></center>
</table>
</form>
<div align="center">
<center><b>共有<font color="#FF0000">(<%=SqlRecSet.RecordCount%>)</font>条记录符合查询要求</b></center>
<table width="731" border="1" align="center"
cellspacing="0" bordercolor="#000000"
bordercolorlight="#000000" bordercolordark="#FFFFFF">
</table>
<tr class="tableth1"><td height="22" width="725"><table width="853" border="1" align="center"
cellspacing="0" bordercolor="#000000"
bordercolorlight="#000000" bordercolordark="#FFFFFF"><td width="847"><table width="885" border="1" align="center"
cellspacing="0" bordercolor="#000000"
bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr class="tableth1">
<td height="22" width="125">订单号</td>
<td height="22" width="82">订单日期</td>
<td height="22" width="73">物料数量</td>
<td height="22" width="114">物料编码</td>
<td height="22" width="157">物料名称</td>
<td height="22" width="70">供应商</td>
<td height="22" width="96">交货日期</td>
<td height="22" width="96">已收数量</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></td>
</tr>
</body>
</html>