请教,忘记给分了

oaxiazai 2009-07-30 09:05:20
ADODB.Field 错误 '800a0bcd'

BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。

/stafpersoninf.asp,行 135

当没有记录的时候要显示为“请选择要查询的员工”或者默认显示某个人的纪录改怎么改

<%
'读出姓名、部门、职位
set conn=opendb("oabusy","conn","accessdsn")
set rs=server.createobject("adodb.recordset")
sql="select name,userdept,userlevel from userinf where username=" & sqlstr(username)
rs.open sql,conn,1
name=rs("name")
userdept=rs("userdept")
userlevel=rs("userlevel")
'打开数据库,读出个人档案
set conn=opendb("oabusy","conn","accessdsn")
set rs=server.createobject("adodb.recordset")
sql="select * from personinf where username=" & sqlstr(username)
rs.open sql,conn,1
dim a(33)
if not rs.eof and not rs.bof then
for i=1 to 33
a(i)=rs("a" & i)
next
inputdate=rs("inputdate")
updatedate=rs("updatedate")
havephoto=rs("havephoto")
id=rs("id")
else
for i=1 to 33
a(i)=""
next
inputdate=""
updatedate=""
havephoto="no"
end if
%>
...全文
78 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wzywzx 2009-08-20
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 hookee 的回复:]
VBScript code<%'读出姓名、部门、职位set conn=opendb("oabusy","conn","accessdsn")set rs=server.createobject("adodb.recordset")
sql="select name,userdept,userlevel from userinf where username='"& sqlstr(username)¡­
[/Quote]
安3楼的就提示[Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询表达式 'username=''lfz''' 中。

浪尖赏花 2009-07-30
  • 打赏
  • 举报
回复
应该是查询的数据为空了,在循环前加上为空的判断吧
hello晨光 2009-07-30
  • 打赏
  • 举报
回复
请加上
If Not Rs.Eof Then

End IF


--------------------
www.33996.cn
jinjazz 2009-07-30
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 bloomdeng 的回复:]
和数据应该没关系,我理解,她建了个表,表里有33个字段,从a1到a33
[/Quote]
...
哦,我理解错了
toury 2009-07-30
  • 打赏
  • 举报
回复
sql="select name,userdept,userlevel from userinf where username=" & sqlstr(username)
rs.open sql,conn,1,1
if rs.eof then
response.write"查无此人"
rs.close
set rs=nothing
response.end
end if
....
睿睿爸爸 2009-07-30
  • 打赏
  • 举报
回复
和数据应该没关系,我理解,她建了个表,表里有33个字段,从a1到a33
hookee 2009-07-30
  • 打赏
  • 举报
回复

<%
'读出姓名、部门、职位
set conn=opendb("oabusy","conn","accessdsn")
set rs=server.createobject("adodb.recordset")
sql="select name,userdept,userlevel from userinf where username='" & sqlstr(username) & "'"
rs.cursorLocation = 3
rs.open sql,conn,1,1
If Not (rs.eof and rs.bof) then
name=rs("name")
userdept=rs("userdept")
userlevel=rs("userlevel")
else
rs.close
conn.close
response.write "没有记录"
response.end
end if
'打开数据库,读出个人档案
set rs=server.createobject("adodb.recordset")
sql="select * from personinf where username='" & sqlstr(username) & "'"
rs.cursorLocation = 3
rs.open sql,conn,1,1
dim a(33)
if not (rs.eof and rs.bof) then
for i=1 to 33
a(i)=rs("a" & i)
next
inputdate=rs("inputdate")
updatedate=rs("updatedate")
havephoto=rs("havephoto")
id=rs("id")
else
for i=1 to 33
a(i)=""
next
inputdate=""
updatedate=""
havephoto="no"
end if
rs.close
conn.close
%>
qwegis 2009-07-30
  • 打赏
  • 举报
回复
我觉得VBscript的数组下标应该是从0开始的吧 你那里的循环应该是for 0 to 32
jinjazz 2009-07-30
  • 打赏
  • 举报
回复
用while 和eof配合,不要用 for i=1 to 33

28,406

社区成员

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

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