日期:2014-05-17  浏览次数:20969 次

update当前记录集不支持更新?
我想做一个表单修改的作用,但是更新不了,请帮忙看看原因在哪?谢谢.

VBScript code

set conn=server.CreateObject("adodb.connection")
conn.connectionstring="Provider=SQLOLEDB;Server=XXXX;Database=xx;UID=sa;pwd=xx"
conn.open

djh=request("djh")

set rs=server.CreateObject("adodb.recordset")
Sql="SELECT * FROM tb WHERE djh='"&djh&"' order by xh"
rs.open sql,conn,2,3

if request("sub")<>""then

Do While Not rs.EOF
rs("mddf")=1111
rs.update 
rs.movenext
loop



------解决方案--------------------
VBScript code

<%
set conn = server.CreateObject("adodb.connection")
conn.connectionstring="Provider=SQLOLEDB;Server=XXXX;Database=xx;UID=sa;pwd=xx"
conn.open
djh=request("djh")
set rs=server.CreateObject("adodb.recordset")
Sql="SELECT * FROM tb WHERE djh='" & Replace(djh, "'","''") & "'"
rs.CursorLocation = 3
rs.open sql,conn,1,3
If Not (rs.EOF And rs.BOF) Then
  Do While Not rs.EOF
     rs("mddf")=1111
     rs.movenext
  loop
  rs.update 
End If
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing

%>