查看: 700|回复: 7
|
Operation must be an updatable query.
[复制链接]
|
|
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 编辑 ] |
|
|
|
|
|
|
|
发表于 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
|
显示全部楼层
|
|
|
|
|
|
|

楼主 |
发表于 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) |
|
|
|
|
|
|
|
发表于 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不能用。旧的方法可以用。 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|