数据通过查询取出来了,但点下一页,就回到出错页面,不知是什么原因,高分求助

schuanghao 2006-10-26 08:44:04
数据取出来了,但现在的又出了新的问题(分页又不对),再帮我看一下是什么原因引起的。

在取出的页面里点“下一页”它说“数据库中没有我想要的记录”但明明有记录。

我把代码粘出来,各位在帮我看看,小弟不胜感激!!!!!!

<!--#include file= "OnePage.fun " -- >
<html >
<title >维修状态查询 </title >
<link rel= "stylesheet " href= "style.css " >
<body topmargin= "0 " leftmargin= "0 " bgcolor= "#83ACCD " >
<div align= "center " >
<TABLE border=0 cellPadding=0 cellSpacing=0 width=850 height= "1 " >

<tr >
<td width= "100% " height= "43 " style= "border: 1 solid #D9F2FF " >
<p align= "center " > <object classid= "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 " codebase= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0 " width= "851 " height= "56 " title= "ht " >
<param name= "movie " value= "image/ht.swf " >
<param name= "quality " value= "high " >
<embed src= "image/ht.swf " quality= "high " pluginspage= "http://www.macromedia.com/go/getflashplayer " type= "application/x-shockwave-flash " width= "851 " height= "55 " >
</object >
</tr >
</table >
</TD > </TR > </TBODY > </TABLE > </TD >
</TR > </TBODY > </center > </TABLE > </TD > </TR >
</TBODY > </TABLE >



<div align= "center " >
<table bgcolor= "#0066CC " width=850 height= "20 " >
<tr >
<td > <p > <font color= "#FFFFFF " >你现在的位置:- > <a href= "../index.htm " >主页 </a >- > <a href= "index.htm " >维修壮态查询 </a > </font > </td > </p >
</tr >
</center >
</table >
</font > </center >
</div >

<%

Jh = Request.form( "jh ")
Xlh = Request.form( "xlh ")
Sxrqstart = Request.form( "sxrqstart ")
Sxrqend = Request.form( "sxrqend ")
Wcrqstart = Request.form( "wcrqstart ")
Wcrqend = Request.form( "wcrqend ")
Fhrqstart = Request.form( "fhrqstart ")
Fhrqend = Request.form( "fhrqend ")
Wxzt = Request.form( "wxzt ")
Sxdw = Request.form( "sxdw ")
dim sql
sql = " SELECT MC,JH,XLH,SXDW,SXRQ,HTH,WCRQ,YDH,FHRQ,WXBZ,CPZT,WXZT FROM Status WHERE SXDW = ' "&Sxdw& "' "
if Jh < > " " then
sql = sql & " And JH Like ' "&Jh& "%' "
end if
if Xlh < > " " then
sql = sql & " And Xlh Like ' "&Xlh& "%' "
end if
if Sxrqstart < > " " then
sql = sql & " And sxrq >= # "&Sxrqstart& "# "
end if
if Sxrqend < > " " then
sql = sql & " And sxrq <= # "&Sxrqend& "# "
end if
if Wcrqstart < > " " then
sql = sql & " And wcrq >= # "&Wcrqstart& "# "
end if
if Wcrqend < > " " then
sql = sql & " And wcrq <= # "&Wcrqend& "# "
end if
if Fhrqstart < > " " then
sql = sql & " And fhrq >= # "&Fhrqstart& "# "
end if
if Fhrqend < > " " then
sql = sql & " And fhrq <= # "&Fhrqend& "# "
end if
if Wxzt < > " " then
sql = sql & " And WXZT Like ' "&Wxzt& "%' "
end if
set cn = Server.CreateObject( "ADODB.Connection ")

set rs = Server.CreateObject( "ADODB.Recordset ")

cn.Open "status "

set rs.ActiveConnection = cn

rs.Open sql,cn,3,1

rs.PageSize = 25
% >
<%

Page = CLng(Request( "Page "))

If Page > rs.PageCount Then Page = rs.PageCount

If Page < 1 Then Page = 1
ShowOnePage rs, Page
% >
<form >
<input type= "textarea " name= "userid " value= " " > " <%=sql% > "
</form >
<DIV ALIGN=right > <P > <HR >
<FORM Action= <%=Myself% > Method=GET >

<%If Page < > 1 Then ' 如果不是位于第一页% >
<A HREF= <%=Myself% >?Page=1&jh= <%=jh% >&xlh= <%=xlh% >&sxrqstart= <%=sxrqstart% >&sxrqend= <%=sxrqend% >&wcrqstart= <%=wcrqstart% >&wcrqend= <%=wcrqend% >&fhrqstart= <%=fhrqstart% >&fhrqend= <%=fhrqend% >&wxzt= <%=wxzt% >&sxdw= <%=sxdw% > >第一页 </A >
<A HREF= <%=Myself% >?Page= <%=(Page-1)% >&jh= <%=jh% >&xlh= <%=xlh% >&sxrqstart= <%=sxrqstart% >&sxrqend= <%=sxrqend% >&wcrqstart= <%=wcrqstart% >&wcrqend= <%=wcrqend% >&fhrqstart= <%=fhrqstart% >&fhrqend= <%=fhrqend% >&wxzt= <%=wxzt% >&sxdw= <%=sxdw% > >上一页 </A >
<%End If
If Page < > rs.PageCount Then ' 如果不是位于最后一页
% >
<A HREF= <%=Myself% >?Page= <%=(Page+1)% >&jh= <%=jh% >&xlh= <%=xlh% >&sxrqstart= <%=sxrqstart% >&sxrqend= <%=sxrqend% >&wcrqstart= <%=wcrqstart% >&wcrqend= <%=wcrqend% >&fhrqstart= <%=fhrqstart% >&fhrqend= <%=fhrqend% >&wxzt= <%=wxzt% >&sxdw= <%=sxdw% > >下一页 </A >
<A HREF= <%=Myself% >?Page= <%=rs.PageCount% >&jh= <%=jh% >&xlh= <%=xlh% >&sxrqstart= <%=sxrqstart% >&sxrqend= <%=sxrqend% >&wcrqstart= <%=wcrqstart% >&wcrqend= <%=wcrqend% >&fhrqstart= <%=fhrqstart% >&fhrqend= <%=fhrqend% >&wxzt= <%=wxzt% >&sxdw= <%=sxdw% > >最后一页 </A >
<%End If% >
<% if page >1 then % >

页次: <FONT COLOR= "Red " > <%=Page% >/ <%=rs.PageCount% > </FONT >
<% else
% >
页次: <FONT COLOR= "Red " > <%=Page% >/ <%=rs.PageCount% > </FONT >
<% end if% >

</FORM >
</body >
</html >
...全文
247 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
schuanghao 2006-10-26
  • 打赏
  • 举报
回复
各位老大快来帮我看看吧
schuanghao 2006-10-26
  • 打赏
  • 举报
回复
ding
schuanghao 2006-10-26
  • 打赏
  • 举报
回复
谢谢PcVSBirds(pc_birds),你把你的代码粘出来,但我是想你们看看我的代码错在哪儿,该如何来改!!!!
PcVSBirds 2006-10-26
  • 打赏
  • 举报
回复
例子
REM -------------------Code Start---------------------
REM <%@ LANGUAGE = VBScript CodePage = 65001% >'注意% >之间去掉空格
REM <%

REM Option Explicit

REM % >'注意% >之间去掉空格
REM <!--#include virtual="class.connDb.asp" -->
REM <!--#include virtual="class.splitPages.asp" -->
REM <%

REM Const Btn_First="<font face=""webdings"">9</font>" '定义第一页按钮显示样式
REM Const Btn_Prev="<font face=""webdings"">3</font>" '定义前一页按钮显示样式
REM Const Btn_Next="<font face=""webdings"">4</font>" '定义下一页按钮显示样式
REM Const Btn_Last="<font face=""webdings"">:</font>" '定义最后一页按钮显示样式

REM Dim db,Conn,Sql,Rs,splitPage,i

REM Set db = new connDb
REM db.setHost = "127.0.0.1"
REM db.setUser = "51cc"
REM db.setPassowrd = "admin"
REM db.setDatabase = "test"
REM db.setType = "MySQL"
REM db.setDebug = 1
REM db.ConnDb

REM Set Conn = db.Conn

REM Conn.CursorLocation=3

REM Set splitPage=new SplitPages
REM splitPage.setConn=Conn
REM splitPage.setSql="select * from user"
REM splitPage.pageSize=2
REM set Rs=splitPage.getRs()

REM For i=1 to splitPage.PageSize
REM If not Rs.Eof Then
REM Response.Write Rs("id")&" "
REM Response.Write Rs("account")&" "
REM Response.Write Rs("password")
REM Response.Write "<br />"
REM else
REM exit for
REM end if
REM rs.movenext
REM Next
REM splitPage.showPage

REM -------------------Code End---------------------
PcVSBirds 2006-10-26
  • 打赏
  • 举报
回复
<%
REM /************************************************************************/
REM /* Pc Rookie's Tools For ASP: SplitPage Class */
REM /* ========================================================= */
REM /* */
REM /* Copyright (c) 2006 by Pc Rookie's */
REM /* Website http://www.51cc.net */
REM /* Email lyr-25@163.com */
REM /* */
REM /* This program is free software. You can redistribute it and/or modify */
REM /* it under the terms of the GNU General Public License as published by */
REM /* the Free Software Foundation; either version 2 of the License. */
REM /************************************************************************/

REM 参数说明:
REM setSql -- 查询Sql语句
REM setConn -- 数据库链接对象
REM PageSize -- 每页显示记录数量
REM getRs() -- 获取Sql查询返回记录集
REM ShowPage -- 显示分页列表1,2,3,4,5...

REM 分页类调用实例

'Const Btn_First="<font face=""webdings"">9</font>" '定义第一页按钮显示样式
'Const Btn_Prev="<font face=""webdings"">3</font>" '定义前一页按钮显示样式
'Const Btn_Next="<font face=""webdings"">4</font>" '定义下一页按钮显示样式
'Const Btn_Last="<font face=""webdings"">:</font>" '定义最后一页按钮显示样式
'Const XD_Align="Center" '定义分页信息对齐方式
'Const XD_Width="100%" '定义分页信息框大小

Class SplitPages
Private PagesCount
Private ConnPrivate
Private RsPrivate
Private Sql
Private PagesSize
Private Str_errors
Private CurPage
Private Urls
Private TotalPages
Private TotalRecords
Private Surls

Public Property Let pageSize(int_PageSize)
If IsNumeric(Int_Pagesize) Then
PagesSize=CLng(int_PageSize)
Else
str_error=str_error & "参数不正确."
ShowError()
End If
End Property

Public Property Get pageSize
If PagesSize="" or (not(IsNumeric(PagesSize))) Then
PageSize=10
Else
PageSize=PagesSize
End If
End Property

Public Property Get getRs()
Set Rs=Server.createobject("adodb.recordset")
Rs.Open Sql,Conn,1,1
Rs.PageSize=PageSize
If not(Rs.eof and Rs.BOF) Then
If CurPage>Rs.PageCount Then
CurPage=Rs.PageCount
End If
Rs.AbsolutePage=CurPage
End If
Set GetRs=Rs
End Property

Public Property Let setConn(obj_Conn)
Set Conn=obj_Conn
End Property

Public Property Let setSQL(str_sql)
Sql=str_sql
End Property

Private Sub Class_Initialize
PagesSize=10 '设定分页的默认值为10
If request("page")="" Then
CurPage=1
ElseIf not(IsNumeric(request("page"))) Then
CurPage=1
ElseIf CInt(Trim(request("page")))<1 Then
CurPage=1
Else
CurPage=CInt(Trim(request("page")))
End If

End Sub

Public Sub showPage()
Dim str_tmp,str_error
Surls = GetUrl()
TotalRecords=Rs.RecordCount
If TotalRecords<=0 Then
str_error=str_error & "总记录数为零,请输入数据"
Call ShowError()
End If
If TotalRecords="" then
TotalPages=1
Else
If TotalRecords mod PageSize =0 Then
TotalPages = CLng(TotalRecords / PagesSize * -1)*-1
Else
TotalPages = CLng(TotalRecords / PagesSize * -1)*-1+1
End If
End If

If CurPage>TotalPages Then
CurPage=TotalPages
End If

response.write ""
str_tmp=ShowFirstPrv
response.write str_tmp
str_tmp=showNumBtn
response.write str_tmp
str_tmp=ShowNextLast
response.write str_tmp
str_tmp=ShowPageInfo
response.write str_tmp

response.write ""
End Sub

Private Function ShowFirstPrv()
Dim Str_tmp,int_prvpage
If CurPage=1 Then
str_tmp=Btn_First&" "&Btn_Prev
Else
int_prvpage=CurPage-1
str_tmp="<a href="""&Surls & "1" & """>" & Btn_First&"</a> <a href=""" & Surls & CStr(int_prvpage) & """>" & Btn_Prev&"</a> "
End If
ShowFirstPrv=str_tmp
End Function

Private Function ShowNextLast()
Dim str_tmp,int_Nextpage
If CurPage>=TotalPages Then
str_tmp=Btn_Next & " " & Btn_Last
Else
Int_NextPage=CurPage+1
str_tmp="<a href=""" & Surls & CStr(int_nextpage) & """>" & Btn_Next&"</a> <a href="""& Surls & CStr(TotalPages) & """>" & Btn_Last&"</a>"
End If
ShowNextLast=str_tmp
End Function

Private Function showNumBtn()
Dim i,str_tmp
For i=1 to TotalPages
str_tmp=str_tmp & "<a href=""" & Surls & CStr(i) & """>"&i&"</a> "
Next
showNumBtn=str_tmp
End Function

Private Function ShowPageInfo()
Dim str_tmp
str_tmp="  页次:"&CurPage&"/"&TotalPages&"页 共<font color=red>"&TotalRecords&"</font>条记录 "&PagesSize&"条/每页"
ShowPageInfo=str_tmp
End Function

Private Function GetURL()
Dim strurl,Urls,i,j,search_str,result_url,str_params
search_str="page="

strurl=Request.ServerVariables("URL")
Strurl=split(strurl,"/")
i=UBound(strurl,1)
Urls=strurl(i)'得到当前页文件名

str_params=Trim(Request.ServerVariables("QUERY_STRING"))
If str_params="" Then
result_url=Urls & "?page="
Else
If InstrRev(str_params,search_str)=0 Then
result_url=Urls & "?" & str_params &"&page="
Else
j=InstrRev(str_params,search_str)-2
If j=-1 Then
result_url=Urls & "?page="
Else
str_params=Left(str_params,j)
result_url=Urls & "?" & str_params &"&page="
End If
End If
End If
GetURL=result_url
End Function

Private Sub Class_Terminate
Rs.close
Set Rs=nothing
End Sub

Private Sub ShowError()
Dim str_Error
If str_Error <> "" Then
Response.Write("" & str_Error & "")
Response.End
End If
End Sub
End class
%>
sy_binbin 2006-10-26
  • 打赏
  • 举报
回复
把你的SQL语句打出来,看看是不是你想要的

另外要看看分页的时候,你的那些参数带的对不对

28,391

社区成员

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

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