更新

x98188 2004-02-01 12:59:27
代码如下:显示得了,但是更新不了??
<!--#include file="conn.asp"-->

<%
set rs=server.createobject("adodb.recordset")
sql="select * from Class_1"
rs.open sql,conn,1,3
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>类别修改</title>
</head>

<body>
<% do While Not rs.Eof %>
<form name="form1" method="post" action="admin-class.asp?update">
<table width="76%" height="25" border="1">

<tr>
<td> <input name="name1" type="text" value="<%=rs("Class_1_Name")%>">
</td>
<td><input type="submit" name="Submit" value="修改"></td>
<td>删除</td>
</tr>


</table>
</form>
<% rs.movenext
loop
%>

</body>
</html>
<%
if request.querystring ="update" then
rs("Class_1_Name")=request("name1")
rs.update
response.write "修改成功"
end if


rs.close
set rs=nothing
conn.close
%>


...全文
39 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
x98188 2004-02-02
  • 打赏
  • 举报
回复
这个好象都不行啊
青蛙 2004-02-01
  • 打赏
  • 举报
回复
你操作记录的时候并没有打开表,也没有进行记录的读取,当然就无法进行数据的更新了。

改成这样看看。
<!--#include file="conn.asp"-->

<%
set rs=server.createobject("adodb.recordset")
sql="select * from Class_1"
rs.open sql,conn,1,3
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>类别修改</title>
</head>

<body>
<% do While Not rs.Eof %>
<form name="form1" method="post" action="admin-class.asp?update&id=<%=idValue%>">
<table width="76%" height="25" border="1">
<tr>
<td> <input name="name1" type="text" value="<%=rs("Class_1_Name")%>">
</td>
<td><input type="submit" name="Submit" value="修改"></td>
<td>删除</td>
</tr>
</table>
</form>
<% rs.movenext
loop
%>
</body>
</html>
<%
if request.querystring ="update" then
id = request.querystring("id")
set editRs = server.createobject("adodb.recordset")
editRs.open "select * from class_1 where id=" + id, conn, 2,3
rs("Class_1_Name")=request("name1")
rs.update
response.write "修改成功"
end if
rs.close
set rs=nothing
conn.close
%>

28,407

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧