注册 登录
编程论坛 ASP技术论坛

ADODB.Field (0x80020009)这是怎么一回事

kombel 发布于 2011-08-04 10:40, 969 次点击
错误类型:
ADODB.Field (0x80020009)
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。
/admin/finlist.asp
程序代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../Connections/conn.asp" -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.>
<html xmlns="http://www.>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE1
{    font-size: 36px;
    font-weight
: bold;
}
-->
</style>
</head>

<body>
<table width="600" border="0" cellpadding="5" cellspacing="0" bordercolor="#E8E09F" align="center" >
  <tr>
    <td colspan="3" align="center" nowrap="nowrap" bgcolor="#F3EFCD" class="STYLE7"><span class="STYLE1">详单</span></td>
  </tr>
  <tr>
    <%cx = request("id")
sql
= "select * from pay where author like '%"&cx& "%' order by id desc"
set rs=server.createobject("adodb.recordset")'
  rs.open sql,conn,1,1

 
%>
    <%if rs.bof then
response.write
"<td align='center'><strong>对不起!没有相关的记录</strong></td>"
response.end
end if
%>
    <td colspan="1" nowrap="nowrap" bgcolor="#F3EFCD" class="STYLE7 " align="left"><strong>客户名称:<%=rs("user")%></strong></td>
    <td nowrap="nowrap" bgcolor="#F3EFCD" colspan="1" class="STYLE7 "  align="center"><strong> 电话:</strong></td>
    <td nowrap="nowrap" bgcolor="#F3EFCD" colspan="1" class="STYLE7 " align="right"><strong>NO. <%=rs("no")%></strong></td>
  </tr>
</table>
<table width="600" border="1" cellpadding="5" cellspacing="0" bordercolor="#E8E09F"  id="detailItem" align="center" >
  <tr>
    <td  nowrap="nowrap" bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>商品名称</strong></td>
    <td   nowrap="nowrap" bgcolor="#F3EFCD" class="td1 STYLE7" align="center"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></td>
    <td  nowrap="nowrap" bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>单位</strong></td>
    <td  nowrap="nowrap" bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>数量</strong></td>
    <td   nowrap="nowrap" bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>单价</strong></td>
    <td   nowrap="nowrap" bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>金额</strong></td>
  </tr>
  <%
sum1
=0    '总金额初始值=0
WHILE NOT RS.EOF
%>
  <tr >
    <td   nowrap="nowrap" bgcolor="#F3EFCD"  align="center"><%=rs("name")%></td>
    <td   nowrap="nowrap" bgcolor="#F3EFCD" align="center"><%=rs("size")%></td>
    <td   nowrap="nowrap" bgcolor="#F3EFCD" align="center"><%unit=rs("unit")
                                                        response.write(unit)
%></td>
    <td  nowrap="nowrap" bgcolor="#F3EFCD" align="center"><%quantity=rs("quantity")
                                                   response.write(quantity)
%></td>
    <td  nowrap="nowrap" bgcolor="#F3EFCD" align="center"><%pric=rs("pric")
                                                 sum
=pric*quantity
                                                   sum1
=sum1+sum
                                                   response.write(pric)
                                                   
%></td>
    <td nowrap="nowrap" bgcolor="#F3EFCD" align="center"><% response.write(sum)%></td>
  </tr>
  <%RS.MoveNext
WEND%>
</table>
<table width="600" border="1" cellpadding="5" cellspacing="0" bordercolor="#E8E09F"  id="detailItem" align="center" >
  <tr>
    <%   
  
dim   a   '要转换成大写的金额   
  dim   atoc   '转换之后的值   
  Dim   String1   '如下定义   
  Dim   String2   '如下定义   
  Dim   String3   '从原A值中取出的值   
  Dim   I   '循环变量   
  Dim   J   'A的值乘以100的字符串长度   
  Dim   Ch1   '数字的汉语读法   
  Dim   Ch2   '数字位的汉字读法   
  Dim   nZero   '用来计算连续的零值是几个
   
  a
=sum1
  String1   
=   "零壹贰叁肆伍陆柒捌玖"   
  String2   
=   "万仟佰拾亿仟佰拾万仟佰拾元角分"   
  nZero   
=   0   
   
  
If   InStr(1,   CStr(a   *   100),   ".")   <>   0   Then   
  err.Raise   
5000,   ,   "此函数(   AtoC()   )只能转换小数点后有两位以内的数!"   
  
End   If   
   
  J   
=   Len(CStr(a   *   100))   
  String2   
=   Right(String2,   J)   '取出对应位数的STRING2的值   
   
  
For   I   =   1   To   J   
  String3   
=   Mid(a   *   100,   I,   1)   '取出需转换的某一位的值   
   
  
If I <>(J - 3) + 1 And I <> (J  - 7) + 1And I <>  (J - 11) + 1  And I  <>(J  -   15)   +   1   Then   
  
If   String3   =   0   Then   
  Ch1   
=   ""   
  Ch2   
=   ""   
  nZero   
=   nZero   +   1   
  
ElseIf   String3   <>   0   And   nZero   <>   0   Then   
  Ch1   
=   ""   &   Mid(String1,   clng(String3)   +   1,   1)   
  Ch2   
=   Mid(String2,   I,   1)   
  nZero   
=   0   
  
Else   
  Ch1   
=   Mid(String1,   clng(String3)   +   1,   1)   
  Ch2   
=   Mid(String2,   I,   1)   
  nZero   
=   0   
  
End   If   
  
Else   '该位是万亿,亿,万,元位等关键位   
  If   String3   <>   0   And   nZero   <>   0   Then   
  Ch1   
=   ""   &   Mid(String1,   clng(String3)   +   1,   1)   
  Ch2   
=   Mid(String2,   I,   1)   
  nZero   
=   0   
  
ElseIf   String3   <>   0   And   nZero   =   0   Then   
  Ch1   
=   Mid(String1,   clng(String3)   +   1,   1)   
  Ch2   
=   Mid(String2,   I,   1)   
  nZero   
=   0   
  
ElseIf   String3   =   0   And   nZero   >=   3   Then   
  Ch1   
=   ""   
  Ch2   
=   ""   
  nZero   
=   nZero   +   1   
  
Else   
  Ch1   
=   ""   
  Ch2   
=   Mid(String2,   I,   1)   
  nZero   
=   nZero   +   1   
  
End   If   
   
  
If   I=(J -11)+1Or   I   =   (J   -   3)   +   1   Then   '如果该位是亿位或元位,则必须写上   
  Ch2   =   Mid(String2,   I,   1)   
  
End   If   
   
  
End   If   
  AtoC   
=   AtoC   &   Ch1   &   Ch2   
   
  
If   I   =   J   And   String3   =   0   Then   '最后一位(分)为0时,加上“整”   
  AtoC   =   AtoC   &   ""   
  
End   If   
   
  
Next   
  
if   a=0   then   
  atoc
="零元整"   
  
end   if
   
%>
    <td width="90" align="center" nowrap="nowrap" bgcolor="#F3EFCD" class="STYLE7 "><strong>合计大写:</strong></td>
    <td width="360" align="center" nowrap="nowrap" bgcolor="#F3EFCD" class="STYLE7 "><%=atoc%>&nbsp;</td>
    <td width="120" align="left" nowrap="nowrap" bgcolor="#F3EFCD" class="STYLE7 "><span class="admintitle"><strong></strong></span>:<%=sum1%></td>
  </tr>
</table>
<table width="600" border="0" cellpadding="5" cellspacing="0" bordercolor="#E8E09F"  id="detailItem" align="center" >
  <tr>
    <td  nowrap="nowrap" bgcolor="#F3EFCD" class="STYLE7"><strong>制单人:
          <%response.write(rs("jidan"))%>
    </strong></td>
  </tr>
</table>
</body>
</html>



11 回复
#2
dzt00012011-08-04 10:47
记录集为空,没有查询到这个id的记录
#3
kombel2011-08-04 10:51
回复 2楼 dzt0001
有的啊    没有怎么没有显示  我有加判断的啊
#4
dzt00012011-08-04 10:54
错误行是哪行?
#5
kombel2011-08-04 11:06
回复 4楼 dzt0001
错误提示就是这些:
错误类型:
ADODB.Field (0x80020009)
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。
/admin/finlist.asp
#6
dzt00012011-08-04 11:12
需要看一下表的结构和数据

[ 本帖最后由 dzt0001 于 2011-8-4 12:34 编辑 ]
#7
kombel2011-08-04 11:22
回复 6楼 dzt0001
只有本站会员才能查看附件,请 登录
#8
dzt00012011-08-04 12:43
没看到有jidan这个字段,估计是截图没截下来。
假设有这个字段,在你显示“制单人”前,所有记录已经遍历完成,此时已经是rs.eof(记录集指针在最后一条记录之后),所以没办法读取rs("jidan")
#9
kombel2011-08-04 13:46
回复 8楼 dzt0001
那怎么解决这个问题呢
#10
噶么噶么2011-08-04 13:48
学习
可以在遍历前给变量赋值
假如有
 jidan=rs("jidan")

最后用response.write(jidan)输出

[ 本帖最后由 噶么噶么 于 2011-8-4 14:01 编辑 ]
#11
dzt00012011-08-04 14:01

if rs.bof then
.....没有相关的记录
end if
这段后面加
jidan=Rs("jidan")



将<%response.write(rs("jidan"))%>
改为<%=jidan"%>
#12
kombel2011-08-04 14:28
回复 11楼 dzt0001
谢谢
1