帮助,遇到怪事了!

jamd 2001-07-16 10:43:17
把变量从一个页面传到另一个页面,根据变量显示库中的记录,每当显示时第一页是对的,第二页就出错了。也不知道是什么原因。
...全文
50 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
jamd 2001-07-18
怎么没人帮看看啦!
回复
homerocker 2001-07-17
可以用全局变量的呀,另然麻烦一点就是在程序的开头重定义applation变量。
回复
jamd 2001-07-17
先显示的是ypcx5.asp
回复
jamd 2001-07-17
我把代码粘出来!
*****************ypcx.asp********
<%@ LANGUAGE="VBSCRIPT" %>
<%option explicit%>
<!--#include file="adovbs.inc"-->

<%Dim RecordPerPage, absPageNum, TotalPages, absRecordNum, rsTest, StrSQL,conn
set conn=server.createobject("adodb.connection")
conn.connectionstring="driver={sql server};server=pri_ntserver;uid=sa;pwd=;database=hospital"
conn.open

RecordPerPage =13 '每页显示的记录数
' 创建记录集对象
StrSQL = "select y_h1.y_ypdm,y_h1.y_ypmc,y_h1.y_ypdj,y_h1.y_ypgg,y_ypdw.y_dwmc,y_h1.y_dwsl,y_ypzl.y_zlmc from y_h1,y_ypdw,y_ypzl where y_h1.Y_xdw=y_ypdw.y_dwbm and y_h1.y_zlbm=y_ypzl.y_zlbm and y_ypdm="'"&yp&"'""
Set rsTest = Server.CreateObject("ADODB.Recordset")
rsTest.CursorLocation = adUseClient '这样设置可减轻数据库负载
rsTest.CursorType = adOpenStatic '游标需要前后移动,不能设为仅向前
rsTest.CacheSize = RecordPerPage '设置这个选项会提高性能


rsTest.Open StrSQL, Conn, , , adCmdText

rsTest.PageSize = RecordPerPage '设置每一页的记录数
If Request.ServerVariables("CONTENT_LENGTH") = 0 Then
'若没收到表单递交的数据(如首次加载该页时), 则从第 1 页开始显示
absPageNum = 1
Else
'取出按 按钮 时的页码
absPageNum = CInt(Request.Form("PressPageNum"))
'如按 上一页 则页码 -1, 按 下一页, 则页码 +1
If Request.Form("Sub") = "上一页" Then
absPageNum = absPageNum - 1
ElseIf Request.Form("Sub") = "下一页" Then
absPageNum = absPageNum + 1
End If
End If


If Not(rsTest.EOF) Then
rsTest.AbsolutePage = absPageNum
End If
TotalPages = rsTest.PageCount
%>

<% ' 下面部分 输出当前页的数据至浏览器 %>
<Html>
<body leftmargin="0" topmargin="0" scroll="no">
<div id="Layer3" style="position:absolute; left:2px; top:553px; width:785px; height:47px; z-index:3"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="800" height="50">
<param name=movie value="cdxh/cdxh.swf">
<param name=quality value=high>
<embed src="cdxh/cdxh.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="800" height="50">
</embed>
</object></div>
<div id="Layer4" style="position:absolute; left:1px; top:334px; width:121px; height:217px; z-index:4"><img src="main2.gif" width="120" height="219" align="middle"></div>
<div id="Layer5" style="position:absolute; left:-1px; top:37px; width:154px; height:252px; z-index:5; overflow: hidden"><img src="ypcx.jpg" width="165" height="250"></div>
<div id="Layer6" style="position:absolute; left:585px; top:497px; width:215px; height:64px"><a href="javascript:window.close();"></a><a href="index.htm"><img src="quit.gif" width="234" height="55" border="0"></a></div>
<Boby>
<div id="Layer1" style="position:absolute; left:0px; top:-3px; width:813px; height:37px; z-index:1"><img src="smzy.jpg" width="815" height="40"></div>
<div id="Layer2" style="position:absolute; left:164px; top:38px; width:651px; height:486px; z-index:2; overflow: visible">
<table colspan=8 cellpadding=5 border=0 width="651">
<tr bgcolor="#800000">
<td align=CENTER width="72"> <font style="ARIAL NARROW" color="#ffffff" size="2">药品代码</font></td>
<td align=CENTER width="106"><font style="ARIAL NARROW" color="#ffffff" size="2">药品名称</font></td>
<td align=CENTER width="86"> <font style="ARIAL NARROW" color="#ffffff" size="2">药品单位</font></td>
<td align=CENTER width="60"> <font style="ARIAL NARROW" color="#ffffff" size="2">药品单价</font></td>
<td align=CENTER width="64"> <font style="ARIAL NARROW" color="#ffffff" size="2">药品规格</font></td>
<td align=CENTER width="87"> <font style="ARIAL NARROW" color="#ffffff" size="2">单位数量</font></td>
<td align=CENTER width="90"> <font style="ARIAL NARROW" color="#ffffff" size="2">药品种类</font></td>
</tr>
<%
For absRecordNum = 1 to rsTest.PageSize
%>
<tr>
<td bgcolor="f7efde" align=CENTER width="72"> <font style="ARIAL NARROW" size="2"><%= rsTest("y_ypdm")%></font></td>
<td bgcolor="f7efde" align=left width="106"> <font style="ARIAL NARROW" size="2"><%= rsTest("y_ypmc")%></font></td>
<td bgcolor="f7efde" align=CENTER width="86"> <font style="ARIAL NARROW" size="2"><%= rsTest("y_dwmc")%></font></td>
<td bgcolor="f7efde" align=CENTER width="60"> <font style="ARIAL NARROW" size="2"><%= rsTest("Y_ypdj")%></font></td>
<td bgcolor="f7efde" align=CENTER width="64"> <font style="ARIAL NARROW" size="2"><%= rsTest("y_ypgg")%></font></td>
<td bgcolor="f7efde" align=CENTER width="87"> <font style="ARIAL NARROW" size="2"><%= rsTest("Y_dwsl")%></font></td>
<td bgcolor="f7efde" align=CENTER width="90"> <font style="ARIAL NARROW" size="2"><%= rsTest("y_zlmc")%></font></td>
</tr>
<%
rsTest.MoveNext
If rsTest.EOF or rstest.bof Then
Exit For ' 如果已到记录尾, 退出 - 如最后一页数据不满页时
End If
next
rsTest.Close : Conn.Close
Set rsTest = Nothing : Set Conn = Nothing
%>
</table>

<% ' 下面部分 是两个按钮 "上一页" "下一页" %>

<Form Action = "<%= Request.ServerVariables("SCRIPT_NAME") %>" Method="Post">
<div align="center">
<Input Type="Hidden" Name="PressPageNum" Value="<%= absPageNum%>">
<%
If absPageNum > 1 Then '如果当前不是第一页, 则显示上一页按钮 %>
<Input Type="submit" Name="Sub" Value="上一页">
<% End If
If absPageNum <> TotalPages Then '如果当前页不是最后一页, 则显示下一页按钮%>
<Input Type="Submit" Name="Sub" Value="下一页">
<% End If %> </div>
</Form>
<P><Center>
[ 第 <font color="#CC0033"><%= absPageNum %></font> 页, 共 <font color="#CC0033"><%= TotalPages %></font>
页 ]
</Center></P></div>
</BODY></HTML>
**************ypcx5.asp*************
<%@ LANGUAGE="VBSCRIPT" %>
<%Option Explicit%>
<%
dim conn,rs,yp,strsql
set conn=server.createobject("adodb.connection")
conn.connectionstring="driver={sql server};server=pri_ntserver;uid=sa;pwd=;database=hospital"
conn.open

strsql = "select id,c_zm from c_zmb"
'创建recordset对象
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 3
%>
<html>
<head>
<title>选择字母</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body scroll="no" bgcolor="#ffffff" leftmargin="0" topmargin="00">
<div id="Layer1" style="position:absolute; left:252px; top:157px; width:540px; height:292px; z-index:1">
<%if rs.eof or rs.bof then%> <%
else
RS.movefirst '移动到下一个记录
do while not rs.EOF '使用do while...loop循环显示所有记录
%> <font color="#000000" size="10"><a href="#" onClick="javascript:window.open('ypcx.asp?yp=<%=rs("c_zm")%>','window99',
'fullscreen=yes')"><%=rs("c_zm")%></a>    </font> <%
rs.movenext
loop
end if
%> <br>
<%
rs.close
set rs = nothing
conn.close
set conn= nothing
%>

</div>
<div id="Layer2" style="position:absolute; left:1px; top:0px; width:836px; height:40px; z-index:2">
<div id="Layer6" style="position:absolute; left:585px; top:494px; width:233px; height:36px; z-index:6"><a href="index.htm"><img src="quit.gif" width="234" height="55" border="0"></a></div>
<img src="smzy.jpg" width="806" height="40"></div>
<div id="Layer3" style="position:absolute; left:-7px; top:551px; width:825px; height:51px; z-index:3"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="800" height="50">
<param name=movie value="cdxh/cdxh.swf">
<param name=quality value=high>
<embed src="cdxh/cdxh.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="800" height="50">
</embed>
</object></div>
<div id="Layer4" style="position:absolute; left:0px; top:39px; width:224px; height:238px; z-index:4; overflow: hidden"><img src="ypcx.jpg" width="250" height="250"></div>
<div id="Layer5" style="position:absolute; left:265px; top:102px; width:517px; height:40px; z-index:5">
<p>请选择您要查询药品名称第一个字母的声母就行查询(如感冒通,选择“"G"字母即可) </p>
</div>
<div align="center"> </div>
</body>
</html>


回复
freezwy 2001-07-16
在其他也面也要使用HIDDEN变量把你的“条件变量”给传递过来就可以了。最简单的是使用list.asp?vcode=1010&page=2,这个vcode就是你第一次传递过来的用户选择的条件。可以写成一个函数来分页显示。
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2001-07-16 10:43
社区公告
暂无公告