中意知识网 中意知识网

当前位置: 首页 » 常用知识 »

asp中修改数据库记录问题请教

asp中修改数据库记录问题请教

<%
id=Request.form("id")
rcontent=request.form("rcontent")
if rcontent=empty then
response.write ""
response.end
end if
sql = "update main set rcontent='"&rcontent&"' where id="&id
conn.execute(sql)
conn.close
%>

==================
rs是adodb.recordset,execute是要用adodb.Connection执行的

<%
id=Request.form("id")
rcontent=request.form("rcontent")
if rcontent=empty then
response.write ""
response.end
end if
sql = "update main set rcontent='"&rcontent&"' where id="&id&""
conn.execute(sql)
conn.close
%>
两种方式:
<%
set rs=server.createobject("adodb.recordset")
id=Request.form("id")
rcontent=request.form("rcontent")
if rcontent=empty then
response.write ""
response.end
end if
sql = "update main set rcontent='"&rcontent&"' where id="&id
rs.open sql,conn,1,3
rs.close
set rs=nothing
%>

<%
id=Request.form("id")
rcontent=request.form("rcontent")
if rcontent=empty then
response.write ""
response.end
end if
sql = "update main set rcontent='"&rcontent&"' where id="&id
conn.execute(sql)
conn.close
%>
未经允许不得转载: 中意知识网 » asp中修改数据库记录问题请教