无法分页!!救命!!

easybjc 2003-09-16 04:54:32
当我从第一个页面的一个表单向第二个页面递交了两个查询参数后,在第二也显示了查询的结果,但是按下“下一页“按钮,出错,不能分页,提示我的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>


...全文
86 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
楚人无衣 2003-09-16
  • 打赏
  • 举报
回复
你的太长,没看完,改一点看看:
<%
if trim(request("deptid"))<>"" then session("deptid")=trim(request("deptid"))
if trim(request("wkdate"))<>"" then session("wkdate")=trim(request("wkdate"))
%>
在代码中用到deptid、wkdate的地方分别用session("deptid")、session("wkdate")代替
marry7 2003-09-16
  • 打赏
  • 举报
回复
没时间给你看,我给你发了短消息,里面放了我实现好用的页,可参考一下

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧