无法分页!!救命!!
当我从第一个页面的一个表单向第二个页面递交了两个查询参数后,在第二也显示了查询的结果,但是按下“下一页“按钮,出错,不能分页,提示我的sql查询语句有错。
<!--#include file="../Connections/bkconn.asp"->
<%
deptid=trim(request("deptid"))
wkdate=trim(request("wkdate"))
%>
<%
Dim rs1
Dim rs1_numRows
Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.ActiveConnection = connstr
rs1.Source = "SELECT deptid, Deptnm FROM dbo.def_department"
rs1.CursorType = 0
rs1.CursorLocation = 2
rs1.LockType = 1
rs1.Open()
rs1_numRows = 0
%>
<html>
<head>
<link rel="stylesheet" href="../main.css" type="text/css">
<script language="javascript" src="../Js/Calendar.js"></script>
</head>
<body leftmargin="0" topmargin="0">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><TABLE width="120" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD CLASS="TableLabel_Oneslef">²úÆ·Èë¿â±¨±í</TD>
<TD WIDTH="9"><IMG SRC="../images/title_corner.gif" width="11" height="22" ></TD>
</TR>
</TABLE></td>
</tr>
<tr>
<td height="229" valign="top">
<table width="90%" border="1" CLASS="table_outer">
<tr>
<td width="86%" height="201">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000" class="ColHeading">
<form method="post" action="mdcprkb_search.asp" name="form1" >
<tr>
<td height="27" bgcolor="#FFFFFF" ><div align="center">µêÃæÃû³Æ
<select name="deptid" >
<%
While (NOT rs1.EOF)
%>
<option value="<%=(rs1.Fields.Item("deptid").Value)%>" <%If (Not isNull((rs1.Fields.Item("Deptnm").Value))) Then If (CStr(rs1.Fields.Item("deptid").Value) = CStr((rs1.Fields.Item("Deptnm").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(rs1.Fields.Item("Deptnm").Value)%></option>
<%
rs1.MoveNext()
Wend
If (rs1.CursorType > 0) Then
rs1.MoveFirst
Else
rs1.Requery
End If
%>
</select>
±¨±íÈÕÆÚ
<input name="wkdate" type="text" size="10" onclick="getDate(this,'2')" readonly value=<%=now()%> >
<input type="submit" name="Submit" value="´ò ¿ª">
</div></td>
</tr>
</form>
</table>
<br>
<%
dim sqltext,rs,thisUrl
if len(deptid)=2 then
thisUrl="mdcprkb_search.asp?true=1&deptid=" & deptid & "&wkdate='" & wkdate & "'"
sqltext="select prdctid,prdctnm,inprc,sum(sl) as sl from rec_prdctin where deptid=" & deptid & "and wkdate='" & wkdate & "' group by prdctid,prdctnm,inprc"
end if
if len(deptid)=4 then
thisUrl="mdcprkb_search.asp?true=1&deptid=" & deptid & "&wkdate='" & wkdate & "'"
sqltext="select deptid,wkdate,prdctid,prdctnm,inprc,sl from rec_prdctin where deptid='" & deptid & "' and wkdate='" & wkdate & "'"
end if
dim page,maxPerPage
maxPerPage=10'ÿҳÏÔʾµÄ¼Ç¼Êý
page=Request("page")
if (page="" or isempty(page)) then page=1
set rs=server.CreateObject("adodb.recordset")
rs.open sqltext,conn,1,1
rs.pagesize=MaxPerPage
%>
<br>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
<tr bgcolor="#FFFFFF">
<td width="134" class="ColHeading"><div align="center">²úÆ·´úÂë</div></td>
<td width="204" class="ColHeading"><div align="center">²úÆ·Ãû³Æ</div></td>
<td width="144" class="ColHeading"><div align="center">½áËã¼Û</div></td>
<td width="147" class="ColHeading"><div align="center">Èë¿âÊýÁ¿</div></td>
</tr>
<%
i=1
if not (rs.eof or err) then rs.move (page-1)*maxPerPage
do while not (rs.eof or err)
%>
<tr bgcolor="#FFFFFF">
<td><div align="center"><%=rs("prdctid")%></div></td>
<td width="204"><div align="center"><%=rs("prdctnm")%></div></td>
<td width="144"><div align="center"><%=rs("inprc")%></div></td>
<td width="147"><div align="center"><%=rs("sl")%></div></td>
</tr>
<%
i=i+1
if i>maxPerPage then exit do
rs.moveNext
loop
%>
</table>
<table width="90%" height="25" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="23" nowrap> <div align="right"><%=rs.recordCount%> Ïî¡¡µÚ<%=page%>/<%=rs.pageCount%> Ò³¡¡
<%if page>1 then%>
<input type="button" name="Submit3" value="Ê×Ò³" onClick="Javascript:jumpTo(1)" style="font-size: 9pt; ">
<input type="submit" name="Submit4" value="ÉÏÒ³" onClick="Javascript:jumpTo(2)" style="font-size: 9pt; ">
<%else%>
<input type="button" name="Submit32" value="Ê×Ò³" style="font-size: 9pt; " disabled>
<input type="submit" name="Submit4" value="ÉÏÒ³" style="font-size: 9pt; " disabled>
<%end if
if rs.recordCount>page*maxPerPage then%>
<input type="submit" name="Submit5" value="ÏÂÒ³" onClick="Javascript:jumpTo(3)" style="font-size: 9pt; ">
<input type="submit" name="Submit6" value="ĩҳ" onClick="Javascript:jumpTo(4)" style="font-size: 9pt; ">
<%else%>
<input type="submit" name="Submit5" value="ÏÂÒ³" style="font-size: 9pt; " disabled>
<input type="submit" name="Submit6" value="ĩҳ" style="font-size: 9pt; " disabled>
<% end if %>
</div></td>
</tr>
</table><br>
</table>
<p> </p></td>
</tr>
</table> </td>
</tr>
</table>
</body>
</html>
<script language=Javascript>
<!--
function jumpTo(i){
if(i==1){
this.document.location="<%=thisUrl%>";}
if(i==2){
this.document.location="<%=thisUrl%>&page=<%=page-1%>";}
if(i==3){
this.document.location="<%=thisUrl%>&page=<%=page+1%>";}
if(i==4){
this.document.location="<%=thisUrl%>&page=<%=rs.pageCount%>";}
}
//-->
</script>