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

高手指点,为何总是无法加入新的记录!

nxz7z8 发布于 2009-07-27 16:37, 387 次点击
最近在学的改页面,发现有个现有的代码中,无法加入新的记录请高手指点:

set rs2=server.createobject("adodb.recordset")
sql0="select * from [FOX_category] where category='"&trim(request("category"))&"'"
rs2.open sql0,conn,1,3
if rs2.eof then
rs.addnew
rs("parentid")=0
rs("category")=trim(request("category"))
rs("categoryorder")=trim(request("paixu"))
rs("hide")=0
rs.update
response.write "<li>添加大类成功。"
response.write "<meta http-equiv=refresh content=""1;URL=shangjialb.asp"">"
rs2.close
set rs2=nothing
else
response.write "<li>错误,名称已经存在!"
rs2.close
set rs2=nothing
response.write "<meta http-equiv=refresh content=""2;URL=shangjialb.asp"">"
response.end
end if

这段代码的执行是也没有错误提示,也没有加入新的记录,不知为什么??
6 回复
#2
yms1232009-07-27 16:39
楼主用的是什么数据?
#3
nxz7z82009-07-27 16:41
access
#4
nxz7z82009-07-27 16:43
access
#5
nxz7z82009-07-27 16:45
其中这一句:
sql0="select * from [FOX_category] where category='"&trim(request("category"))&"'"

中的where category='"&trim(request("category"))&"'"起什么作用的,加入新的记录还需要判定条件吗,不太明白这句的意思
#6
孤独冷雨2009-07-27 17:30
rs2.addnew
rs2("parentid")=0
rs2("category")=trim(request("category"))
rs2("categoryorder")=trim(request("paixu"))
rs2("hide")=0
rs2.update
#7
yms1232009-07-27 17:44
以下是引用nxz7z8在2009-7-27 16:45的发言:

其中这一句:
sql0="select * from [FOX_category] where category='"&trim(request("category"))&"'"

中的where category='"&trim(request("category"))&"'"起什么作用的,加入新的记录还需要判定条件吗,不太明白 ...

因为某些时候为关系表添加数据,就要先查询某个表是否存在关联数据。就好像你到银行办信用卡,银行要确定你的身份存在,才能给你办信用卡一样。
楼主先检查一下Access的读写权限是否设置正确。
1