搞了两天没搞定的问题:
从manage_xmzch.asp上传到search_xmzch.asp页上4个变量,分别是kaishishijian/jieshushijian/kaishichanpin/jieshuchanpin.
search_xmzch.asp接收到4个变量后,查询,并分页显示。现在的问题是,如果sql语句不带参数查询则正常分页显示,但如果带了参数,即 where 销售日期>=#"&kaishishijian&"# and 销售日期 <=#"&jieshushijian&"# and 产品编码>='"&kaishichanpin&"' and 产品编码<='"&jieshuchanpin&"' 这一句,则只能显示第一页,第二页等就显示不出来了。提示为:日期的语法错误 在查询表达式 '销售日期>=## and 销售日期 <=## and 产品编码>='' and 产品编码<=''' 中。
/sims/search_xmzch.asp, 第 57 行
可以看到这几个参数没有接收到传递的数据(第一页显示是正常的)
我把search_xmzch.asp的代码贴到这里,跪求高人指点解决:
<!--#include file="Connections/connsims.asp" -->
<!--#include file="inc/eshopcode.asp"-->
<%
if session("user")="" or session("purview")>"1" then
response.write "<script language='javascript'>window.confirm('你无此权限,请返回!')</script>"
response.write "<script language='javascript'>parent.window.history.go(-1);</script>"
response.end
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
body {
margin-top: 5px;
}
-->
</style><title>按产品明细查询结果</title>
<link href="css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.STYLE2 {color: #FFFFFF}
.STYLE3 {color: #FFffff}
-->
</style>
</head>
<body>
<table width="770" height="260" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="46" height="60"><img src="images/bg_r1_c1.jpg" width="46" height="60" /></td>
<td width="676" background="images/bg_r1_c2.jpg"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="45%"> </td>
<td width="55%"><div align="right"><%=session("user")%>
<!--#include file="time.js"-->
</div></td>
</tr>
</table></td>
<td width="48"><img src="images/bg_r1_c3.jpg" width="28" height="60" /></td>
</tr>
<tr>
<td height="153" background="images/bg_r2_c1.jpg"> </td>
<td bgcolor="#FFFFFF"><!--#include file="head/head_xmz.asp" -->
<br>
<table width="712" border="1" cellpadding="5" cellspacing="0" bordercolorlight="#dddddd" bordercolordark="#FFFFFF">
<%
'if kaishishijian="" or jieshushijian="" or kaishichanpin="" or jieshuchanpin="" then
' response.redirect "manage_xmzch.asp"
'end if
set rs=server.createobject("adodb.recordset")
sql="select 销售日期,产品编码,产品名称,产品规格,sum(销售数量) as 数量,round(sum(销售件数),2) as 件数,round(sum(销售金额),2) as 金额 from V_XSRBall where 销售日期>=#"&kaishishijian&"# and 销售日期 <=#"&jieshushijian&"# and 产品编码>='"&kaishichanpin&"' and 产品编码<='"&jieshuchanpin&"' group by 销售日期,产品编码,产品名称,产品规格 order by 销售日期 desc"
'where 销售日期>=#"&kaishishijian&"# and 销售日期 <=#"&jieshushijian&"# and 产品编码>='"&kaishichanpin&"' and 产品编码<='"&jieshuchanpin&"'
rs.open sql,conn,1,1
dim PerPage
PerPage=20
'假如没有数据时
If rs.eof and rs.bof then
response.write "<p align='center'><font color='#ff0000'>还没任何内容</font></p>"
response.end
End if
'取得页数,并判断用户输入的是否数字类型的数据,如不是将以第一页显示
text="0123456789"
Rs.PageSize=PerPage
for i=1 to len(request("page"))
checkpage=instr(1,text,mid(request("page"),i,1))
if checkpage=0 then
exit for
end if
next
If checkpage<>0 then
If NOT IsEmpty(request("page")) Then
CurrentPage=Cint(request("page"))
If CurrentPage < 1 Then CurrentPage = 1
If CurrentPage > Rs.PageCount Then CurrentPage = Rs.PageCount
Else
CurrentPage= 1
End If
If not Rs.eof Then Rs.AbsolutePage = CurrentPage end if
Else
CurrentPage=1
End if
call list
If Rs.recordcount > PerPage then
end if
'显示帖子的子程序
Sub list()%>
<tr>
<td colspan="7"><div align="center">按产品明细查询结果</div></td>
</tr>
<tr>
<td width="97" bgcolor="#efefef"><div align="center">销售日期</div></td>
<td width="82" bgcolor="#efefef"><div align="center">产品编码</div></td>
<td width="93" bgcolor="#efefef"><div align="center">产品名称</div></td>
<td width="90" bgcolor="#efefef"><div align="center">产品规格</div></td>
<td width="84" bgcolor="#efefef"><div align="center">销售数量</div></td>
<td width="87" bgcolor="#efefef"><div align="center">销售件数</div></td>
<td width="93" bgcolor="#efefef"><div align="center">销售金额</div></td>
</tr>
<%
if not rs.eof then
do while not rs.eof
%>
<tr>
<td><div align="center"><%=rs("销售日期")%></div></td>
<td><div align="center"><%=rs("产品编码")%></div></td>
<td><div align="center"><%=rs("产品名称")%></div></td>
<td><div align="center"><%=rs("产品规格")%></div></td>
<td><div align="center"><%=rs("数量")%></div></td>
<td><div align="center"><%=rs("件数")%></div></td>
<td><div align="center"><%=rs("金额")%></div></td>
</tr>
<%
i=i+1
if i-1 > Perpage then exit do
rs.movenext
loop
end if
%>
</table>
<table width="664" border="1" cellpadding="5" cellspacing="0" bordercolorlight="#dddddd" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#eeeeee"> <strong>分页浏览</strong>
<%
Response.write "<strong><font color='#000000'> -> 全部-</font>"
Response.write "共</font>" & "<font color=#FF0000>" & Cstr(Rs.RecordCount) & "</font>" & "<font color='#000000'>条记录</font></strong> "
Response.write "<strong><font color='#000000'>第</font>" & "<font color=#FF0000>" & Cstr(CurrentPage) & "</font>" & "<font color='#000000'>/" & Cstr(rs.pagecount) & "</font></strong> "
If currentpage > 1 Then
response.write "<strong><a href='search_xmzch.asp?&page="+cstr(1)+"'><font color='#000000'>首页</font></a><font color='#ffffff'> </font></strong>"
Response.write "<strong><a href='search_xmzch.asp?page="+Cstr(currentpage-1)+"'><font color='#000000'>上一页</font></a><font color='#ffffff'> </font></strong>"
Else
Response.write "<strong><font color='#000000'>上一页 </font></strong>"
End if
If currentpage < Rs.PageCount Then
Response.write "<strong><a href='search_xmzch.asp?page="+Cstr(currentPage+1)+"'><font color='#000000'>下一页</font></a><font color='#ffffff'> </font>"
Response.write "<a href='search_xmzch.asp?page="+Cstr(Rs.PageCount)+"'><font color='#000000'>尾页</font></a></strong> "
Else
Response.write ""
Response.write "<strong><font color='#000000'>下一页</font></strong> "
End if
%>
<input type='text' name='page' size=4 maxlength=4 class=text4 value="<%=Currentpage%>">
<input class=submit2 type='submit' value='Go' name='cndok'>
</td>
</tr>
</table>
<table width="664" cellpadding="5">
<tr>
<td colspan="5"><div align="center">【<a href='javascript:history.back()'>返回</a>】</div></td>
</tr>
</table>
<br />
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td></td>
</tr>
</table></td>
<td background="images/bg_r2_c3.jpg"> </td>
</tr>
<tr>
<td height="47"><img src="images/bg_r3_c1.jpg" width="46" height="47" /></td>
<td background="images/bg_r3_c2.jpg"> </td>
<td><img src="images/bg_r3_c3.jpg" width="28" height="47" /></td>
</tr>
</table>
<%
End sub
rs.close
%>
</body>
</html>