查询时显示“BOF 或 EOF 中有一个是“真””???

chaliezhou 2009-08-25 07:53:01
小弟初学ASP,想给单位写一个运单查询系统。希望得到的效果是:当客户输入用户名和密码成功登陆后,系统会默认查处该客户的所有运单并以降序排列。如果客户有单号的话也可以按单号查询,但是不知为什么现在输入单号后点查询,系统会提示“BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。”请各位大哥帮忙看看,谢谢大家!

<!--#include file="../../../connections/conn_b.asp"-->
<%
if session("Uname")=false or session("Uname")="" then
Response.Write ("您还没有正常登陆,系统将返回登陆界面")
response.Redirect("login.asp")
end if
%>
<%
Dim rs,userid,cargo_no
cargo_no=request("cargo_no") '获取单号
set rs=Server.CreateObject("adodb.recordset") '创建recordset对象
'userid=request.Form("txt_name")

sqlstr="select T_JiChNR.P2, T_Bills.pbillno,T_Bills.pdate,T_Bills.ptypebill,T_Bills.pshippercom,T_Bills.pshipperadd,T_Bills.pconsigneecom,T_Bills.pconsigneeadd,T_Bills.pcargoname,T_Bills.ptotalnum,T_Bills.punit,T_Bills.ptrackresult,T_Bills.psignman from T_JiChNR INNER JOIN T_Bills ON T_JiChNR.P2 = T_Bills.pShipperCom where 1=1 "

if request("cargo_no")<>"" then

sqlstr=sqlstr&"and T_JiChNR.P2 = '" & Session("Uname") & "' and T_Bills.pbillno=' " & request("cargo_no") & " ' order by pdate desc"

rs.open sqlstr,conn,1,1

else

sqlstr=sqlstr&"and T_JiChNR.P2 = '" & Session("Uname") & "' order by pdate desc"

rs.open sqlstr,conn,1,1

end if

'if rs.bof and rs.eof then

'end if
%>
<%
show=20
rs.pagesize=show
curpage=Request.QueryString("curpage")
if curpage="" then curpage=1
rs.absolutepage=curpage
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>查询程序</title>
<link href="../../../css/Page_Style.css" rel="stylesheet" type="text/css">

<script type="text/javascript">
function Mycheck()
{
if(document.all.cargo_no.value=="")
{
alert('请输入单号!');return false;
}
return true;}
</script>

<script type="text/javascript" src="jquery/jquery-1.3.2.js" ></script>
<script type="text/javascript">
$(document).ready(function() {
$('.pickme tbody tr:odd').addClass('odd');
$('.pickme tbody tr:even').addClass('even');
$('.pickme tbody tr').hover(
function() { $(this).addClass('highlight'); },
function() { $(this).removeClass('highlight'); }
).click( function() {
$('.selected').removeClass('selected');
$(this).addClass('selected').find('input').attr('checked','checked');
});
});
</script>
</head>

<body>
<table width="1002" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td colspan="2" rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="645" height="76" valign="top" background="../../../picture/Cargo search/background/bg_01.gif"><!--DWLayoutEmptyCell--> </td>
</tr>
</table></td>
<td width="357" height="41" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="357" height="41" valign="top" background="../../../picture/Cargo search/background/bg_02.gif"><div class="toptext">修改密码 | <a class="bot" href="checkUserLogin.asp?action=exit">退出</a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="35" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="357" height="35" valign="top" background="../../../picture/Cargo search/background/bg_03.gif"><div class="logtext"><%= Session("Uname") %>,欢迎登陆!</div></td>
</tr>
</table> </td>
</tr>

<tr>
<td width="479" height="47" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<form name="form1" method="post" action="">
<tr>
<td width="479" height="47" valign="top" background="../../../picture/Cargo search/background/bg_04.gif" style="font-family:'宋体';font-size:12px"><div class="searchtext">单号:
<input class="input_out" type="text" name="cargo_no" id="cargo_no" />
<input type="submit" class="btn3_mouseout" onMouseOver="this.className='btn3_mouseover'" onMouseOut="this.className='btn3_mouseout'" onMouseDown="this.className='btn3_mousedown'" onMouseUp="this.className='btn3_mouseup'" name="button" id="button" value="查询" onclick="return Mycheck()" />
</div></td>
</tr>
</form>
</table></td>
<td colspan="2" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="523" height="47" valign="top" background="../../../picture/Cargo search/background/bg_05.gif">
<div class="text">当前第<%=curpage%>页,共有<%=rs.pagecount%>页,共有:<%=rs.recordcount%>条记录</div>
<div class="text">
<%if curpage=1 then%>
首页
<%else%>
<a href="?curpage=1">首页</a>
<%end if%>

<%if curpage=1 then%>
上一页
<%else%>
<a href="?curpage=<%=curpage-1%>">上一页</a>
<%end if%>

<%if rs.pagecount<curpage+1 then%>
下一页
<%else%>
<a href="?curpage=<%=curpage+1%>">下一页</a>
<%end if%>

<%if rs.pagecount<curpage+1 then%>
尾页
<%else%>
<a href="?curpage=<%=rs.pagecount%>">尾页</a>
<%end if%></div>
</td>
</tr>
</table></td>
</tr>
<tr>
<td height="492" colspan="3" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1002" height="492" valign="top">
<table width="1002" class="record pickme">
<tr>
<th width="76" height="29"><div align="center">
<div align="center">运输单号</div></th>
<th width="66"><div align="center">
<div align="center">开单日期</div></th>
<th width="66"><div align="center">
<div align="center">运输方式</div></th>
<th width="69"><div align="center">
<div align="center">发货单位</div></th>
<th width="83"><div align="center">
<div align="center">起运地址</div></th>
<th width="98"><div align="center">
<div align="center">收货单位</div></th>
<th width="162"><div align="center">
<div align="center">收货地址</div></th>
<th width="69"><div align="center">
<div align="center">货物名称</div></th>
<th width="66"><div align="center">
<div align="center">货物数量</div></th>
<th width="52"><div align="center">
<div align="center">单位</div></th>
<th width="83"><div align="center">
<div align="center">追踪结果</div></th>
<th width="60"><div align="center">
<div align="center">签收人</div></th>
</tr>
<%
'do while not rs.eof

for i= 1 to rs.pagesize
if rs.eof then
'response.Write("没有运单")
exit for
end if

%>
<tr>
<td><div align="center"><%=rs.fields("pBillNo").value%></div></td>
<td><div align="center"><%=rs.fields("pDate").value%></div></td>
<td><div align="center"><%=rs.fields("ptypebill").value%></div></td>
<td><div align="center"><%=rs.fields("pshippercom").value%></div></td>
<td><div align="center"><%=rs.fields("pshipperadd").value%></div></td>
<td><div align="center"><%=rs.fields("pconsigneecom").value%></div></td>
<td><div align="center"><%=rs.fields("pconsigneeadd").value%></div></td>
<td><div align="center"><%=rs.fields("pcargoname").value%></div></td>
<td><div align="center"><%=rs.fields("ptotalnum").value%></div></td>
<td><div align="center"><%=rs.fields("punit").value%></div></td>
<td><div align="center"><%=rs.fields("ptrackresult").value%></div></td>
<td><div align="center"><%=rs.fields("psignman").value%></div></td>
</tr>
<%
rs.movenext
next
%>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="1"></td>
<td width="166"></td>
<td></td>
</tr>
</table>

</body>
</html>

...全文
404 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
toury 2009-08-26
  • 打赏
  • 举报
回复
sqlstr=sqlstr&"and T_JiChNR.P2 = '" & Session("Uname") & "' and T_Bills.pbillno=' " & request("cargo_no") & " ' order by pdate desc"

response.write sqlstr&"<br>"'打印出来这个SQL语句看看什么问题。
chaliezhou 2009-08-26
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 toury 的回复:]
老办法:
response.write Session("Uname")'调试用

if Session("Uname")="" then
  response.write "重新登录吧,登录过期啦"
  response.end
end if

[/Quote]

已经测试了一次,session中是有数据的,晕倒。哈哈
chaliezhou 2009-08-26
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 toury 的回复:]
如果Session("Uname")为空你还让他在你的系统里“转悠”吗?哈哈
[/Quote]

问题就在这里。我的想法是用户在login.asp这个页面中输入账号和密码,点登陆后账户信息会在session中保留下来的。此时系统跳转到search.asp页面,也就是这个出问题的界面。此时<%= Session("Uname") %>,欢迎登陆!这句话中能够显示出正确的用户名,但是sqlstr=sqlstr&"and T_JiChNR.P2 = '" & Session("Uname") & "' and T_Bills.pbillno=' " & request("cargo_no") & " ' order by pdate desc" 这句话不知道为什么就是起不了作用。
toury 2009-08-26
  • 打赏
  • 举报
回复
如果Session("Uname")为空你还让他在你的系统里“转悠”吗?哈哈
toury 2009-08-26
  • 打赏
  • 举报
回复
老办法:
response.write Session("Uname")'调试用

if Session("Uname")="" then
response.write "重新登录吧,登录过期啦"
response.end
end if
chaliezhou 2009-08-26
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 toury 的回复:]
curpage=Request.QueryString("curpage")
response.write curpage&"  //是空的吗? <br>"

如果是空值,那是参数没传递过来,检查分页参数传递部分
[/Quote]

再次感谢toury,还是要继续请教你。出错的具体地方我已经找到了,是这句话:
sqlstr=sqlstr&"and T_JiChNR.P2 = '" & Session("Uname") & "' and T_Bills.pbillno=' " & request("cargo_no") & " ' order by pdate desc"
我是了一下,如果把and T_JiChNR.P2 = '" & Session("Uname") & "'这句删掉,就可以正常查询了。但是如果少了这句似乎就没办法从session中得到登录的账户名信息,这里应该怎样处理会比较好呢?
toury 2009-08-26
  • 打赏
  • 举报
回复
curpage=Request.QueryString("curpage")
response.write curpage&" //是空的吗?<br>"

如果是空值,那是参数没传递过来,检查分页参数传递部分
chaliezhou 2009-08-26
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 toury 的回复:]
sqlstr=sqlstr&"and T_JiChNR.P2 = '" & Session("Uname") & "' and T_Bills.pbillno=' " & request("cargo_no") & " ' order by pdate desc"

response.write sqlstr&" <br>"'打印出来这个SQL语句看看什么问题。

[/Quote]

原因已经找到了,这里的request("cargo_no")应该改成request.form("cargo_no")才可行,可能是这样的简写方式存在问题造成的。
chaliezhou 2009-08-25
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 toury 的回复:]
  'do while not rs.eof

    for i= 1 to rs.pagesize
        if rs.eof then
'response.Write("没有运单")
            exit for
        end if

  %>

--------->
    'do while not rs.eof
    if rs.eof then
      response.Write("没有运单")
      rs.close
      set rs=nothing
      conn.close
      set conn=nothing
      response.end
    end if

    for i= 1 to rs.pagesize


  %>
[/Quote]

谢谢toury,我试过了但是问题依旧,依然提示第39行有错误。会不会是分页代码出了问题?
chaliezhou 2009-08-25
  • 打赏
  • 举报
回复
[Quote=引用 syjeffdyg 的回复:]
自己学下调程序,这样长的代码,眼睛都会看花的!
自己看下哪一行报错?
我估计是你SQL的问题。
[/Quote]

SQL代码已经在SQL SERVER中运行过了,没有问题。

抱歉,是我的错,应该将代码精简一些。浏览器中提示是第39行出现的错误,也就是分页代码那里。

<%
show=20
rs.pagesize=show
curpage=Request.QueryString("curpage")
if curpage="" then curpage=1
[color=#0000FF]rs.absolutepage=curpage ‘这是第39行

%> [/color]

toury 2009-08-25
  • 打赏
  • 举报
回复
'do while not rs.eof

for i= 1 to rs.pagesize
if rs.eof then
'response.Write("没有运单")
exit for
end if

%>


--------->
'do while not rs.eof
if rs.eof then
response.Write("没有运单")
rs.close
set rs=nothing
conn.close
set conn=nothing
response.end
end if

for i= 1 to rs.pagesize


%>
syjeffdyg 2009-08-25
  • 打赏
  • 举报
回复
自己学下调程序,这样长的代码,眼睛都会看花的!
自己看下哪一行报错?
我估计是你SQL的问题。

28,408

社区成员

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

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