佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 701|回复: 7

Operation must be an updatable query.

[复制链接]
发表于 1-3-2006 05:45 PM | 显示全部楼层 |阅读模式
Operation is not allowed when the object is open.
我写了patch data的SQL,出现了

Error Type:
ADODB.Recordset (0x800A0E79)
Operation is not allowed when the object is open.

我的 ASP program:-
<%
set rs=Server.CreateObject("ADODB.Recordset")
set rs2=Server.CreateObject("ADODB.Recordset")
set rs3=Server.CreateObject("ADODB.Recordset")

sql2 = "select * from tbl_customer "

rs.Open sql2,objconn

if not rs.EOF then
 do while not rs.EOF
                custid=rs("cust_id")
                country=rs("cust_country")
       
                SQL="select * from tbl_country where country_code='"& country &"' "
       
                rs3.Open SQL,objconn2  'Error here
                if not rs3.EOF then
                        countryid=rs3("country_id")
                end if       
               
                sql="update tbl_customer set cust_country='"& country_id &"' where cust_id="& clng(custid) &" "
                objconn.execute sql
       
        rs.MoveNext
        loop       

end if

objconn.close
objconn2.Close
rs.Close
rs2.Close
set rs=nothing
set rs2=nothing
%>

[ 本帖最后由 hpeng 于 2-3-2006 01:13 PM 编辑 ]
回复

使用道具 举报


ADVERTISEMENT

发表于 1-3-2006 08:36 PM | 显示全部楼层
你的 rs3 应该先关闭才继续 loop.

                rs3.Open SQL,objconn2  'Error here
                if not rs3.EOF then
                        countryid=rs3("country_id"
                end if
                rs3.Close




根据你现有的 code 来分析, 你应该是在修正 cust_country 吧?
你的 code 太长了, 基本上不需要 loop, 用以下的来 objconn 执行一行 sql 就可以了.
但如果不是你要的请多多包涵....

UPDATE tbl_customer SET cust_country = (SELECT country_id FROM tbl_country WHERE country_code = cust_country)
回复

使用道具 举报

 楼主| 发表于 2-3-2006 09:50 AM | 显示全部楼层
谢谢你,你的SQL很好用,不过我RUN时出现另外一个ERROR,
Operation must be an updatable query.
Error 3073

我的database是ms access,是什么problem?
回复

使用道具 举报

发表于 2-3-2006 03:44 PM | 显示全部楼层
把你的 access 的 permission 改成让大家 write 就可以了,
回复

使用道具 举报

发表于 2-3-2006 03:51 PM | 显示全部楼层
原帖由 hpeng 于 2-3-2006 09:50 AM 发表
谢谢你,你的SQL很好用,不过我RUN时出现另外一个ERROR,
Operation must be an updatable query.
Error 3073

我的database是ms access,是什么problem?


这是Windows的Write Permission问题(http://support.microsoft.com/kb/q175168/),解决方法http://www.xlinesoft.com/asprunn ... e_query__errors.htm
回复

使用道具 举报

 楼主| 发表于 2-3-2006 05:57 PM | 显示全部楼层
别的可以update的,只是这个SQL不能而已。

MS ACCESS database
UPDATE tbl_customer SET cust_country = (SELECT country_id FROM tbl_country WHERE country_code = cust_country)
回复

使用道具 举报

Follow Us
发表于 2-3-2006 07:41 PM | 显示全部楼层
原帖由 hpeng 于 2-3-2006 05:57 PM 发表
别的可以update的,只是这个SQL不能而已。

MS ACCESS database
UPDATE tbl_customer SET cust_country = (SELECT country_id FROM tbl_country WHERE country_code = cust_country)


其它的 UPDATE 可以? 就只有这一个不行?!
出现什么错误呢? 是 Operation must be an updatable query ?!
那么... 还是用回旧的方法吧...
回复

使用道具 举报

 楼主| 发表于 3-3-2006 08:49 AM | 显示全部楼层
谢谢,我觉得可能是ms access 的database不能用。旧的方法可以用。
回复

使用道具 举报


ADVERTISEMENT

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 7-3-2025 03:36 AM , Processed in 0.121756 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表