asp 批量修改sql数据不成功, checkbox 取值错误
以下代码可以运行,但批量修改数据不成功,不知错误在哪里,请问该怎样改数据库表名: web_childdorders
数据库结构:
orderid Shopid C_state
123 abc 1
456 abc 1
789 def 1
<!--#include file=include.asp-->
<%
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
set rss=server.CreateObject("adodb.recordset")
sqls="select * from web_childorders Where Shopid='"&request.cookies("kkshopid")&"'"
rss.open sqls,conn,1,3
%>
<form name="orderChange" method="post" action="?act=update">
<table border="1" width="100%" id="table1">
<tr> <td>
<input type="submit" name="Submit3" value="Submit" onClick="return confirm('Confirm ?');">
</td></tr>
<tr> <td>Item Number</td> </tr>
<%
do while not rss.eof
if rss("C_state")>0 then
%>
<tr><td><input type=checkbox name="ck" value=<%=rss("orderid")%>> <%=rss("orderid")%> </td></tr>
<%
End if
rss.movenext
loop
%>
</table>
</form>
<%
if request("act")="update" and request("ck")<>"" then
''第一种方法,改不了任何数据
''conn.execute("update web_childorders set C_state=6 where orderid in ('"&request("ck")&"')")
''第二种方法,只能改第一个数据
pid=request("ck")
mystr=split(pid,",")
for i=0 to ubound(mystr)
exec="update web_childorders set C_state=6 where orderid ='"&mystr(i)&"'"
conn.execute(exec)
''用response.write 会显示正确的记录
response.write (mystr(i)&"<br>")
next
response.write("Records has been updated")
end if
''第三种方法,成功批量修改数据库
''conn.execute("update web_childorders set C_state=6 where orderid in ('1011042253179022','10112810593074851')")
set rss=nothing
conn.close
set conn = Nothing
%>
另外去掉单引号
conn.execute("update web_childorders set C_state=6 where orderid in ("&request("ck")&")")
会出现
An error occurred on the server when processing the URL. Please contact the system administrator.
If you are the system administrator please click here to find out more about this error.
不知道是不是
<tr><td><input type=checkbox name="ck" value=<%=rss("orderid")%>> <%=rss("orderid")%> </td></tr>
取的是数字,而数据库里的是字符而出现问题?