如何使用sql语句来修改数据记录(2)
来源:CSDN 时间:2007-06-21 11:48:00
2,change.asp
<!--#include file="conn.asp" -->
<%
id=request.querystring("id")
%>
<%if request.form("submit")="change" then
whattitle=request.form("title")
whoauthor=request.form("author")
whatcontent=request.form("content")
id=request.form("id")
Set rs = Server.CreateObject ("ADODB.Recordset")
sql = "Select * from cnarticle where cn_id="&id
rs.Open sql,conn,3,2
rs("cn_title")=whattitle
rs("cn_author")=whoauthor
rs("cn_content")=whatcontent
rs.update
rs.close
Set rs = Nothing
conn.close
set conn=Nothing
response.redirect("showit.asp")
response.end
%>
<%end if%>
<%
if id<>"" then
Set rs = Server.CreateObject ("ADODB.Recordset")
sql="select * from cnarticle where cn_id="&id
rs.Open sql,conn,1,1
whattitle=rs("cn_title")
whoauthor=rs("cn_author")
whatcontent=rs("cn_content")
end if
%>
<form action="change.asp" method="post">
Title:<input type="text" name="title" value=<%=whattitle%>><br>
Author:<input type="text" name="author" value=<%=whoauthor%>><br>
Content:<br>
<textarea name="content" rows="8" cols="30"><%=whatcontent%></textarea><br>
<input type="submit" value="change" name="submit">
<input type="reset" value="Reset">
<input name="id" type="hidden" value="<%=id%>">
</form>
当然所有的检察,安全防护都还没做,BUG多多,自己也来慢慢解决。
另外一类的修改更新使用conn.Execute(sql),
<%if request.form("submit")="change" then
whattitle=request.form("title")
whoauthor=request.form("author")
whatcontent=request.form("content")
id=request.form("id")
sql = "update cnarticle set cn_title=’"&whattitle&"’,cn_author=’"&whoauthor&"’,cn_content=’"&whatcontent&"’ where cn_id="&id
conn.Execute(sql)
conn.close
set conn=Nothing
response.redirect("showit.asp")
response.end
%>
标签:sql,修改记录,update
0
投稿
猜你喜欢
IA学习笔记04:标签系统
2009-09-22 14:40:00
导航设计的流行趋势
2007-12-25 12:06:00
浅析设计与内容呈现的关系
2009-08-06 18:12:00
设计的俗化特征
2010-04-08 16:07:00
Tab(选项卡)的产品设计原则及应用[译]
2009-07-09 19:05:00
ASP中一个字符串处理类加强版
2008-11-25 18:07:00
Asp+ajax打造无刷新新闻评论系统
2008-02-12 15:43:00
Web Forms 2.0
2008-07-24 12:47:00
戴尔是如何设计新官网首页的
2008-07-08 19:02:00
眼未动,心已动【碳酸饮料会】
2009-09-01 19:32:00
教你怎样在Oracle数据库中高速导出/导入
2009-02-04 16:59:00
ASP中将Excel数据导入到Access
2009-02-02 09:15:00
通过分析SQL语句的执行计划优化SQL
2011-10-24 20:03:20
浮动元素对浏览器的支持
2008-02-02 10:05:00
XML HttpRequst对象学习
2007-10-12 19:04:00
js鼠标事件大全
2007-08-13 15:56:00
用jquery写的自动提示效果
2008-06-17 14:27:00
用css+js给网页背景插入flash播放器
2007-10-21 09:27:00
如何用ASP.NET连接MS SQLServer数据库?
2010-06-11 19:27:00
开发iPhone版校友录
2009-08-31 16:29:00