首先声明,我没有学过VB,所以对ASP做网站还是有点陌生,很多东西都是用别人的。自从我工作以后,为了与同事能够配合好,我只有用ASP,ASP.ENT用不上了,呵呵!
代码如下:
<%
dim act,id
act=request.querystring("act")
id=request.querystring("id")
ad_title=request.form("ad_title")
ad_link=request.form("ad_link")
ad_date=request.form("ad_date")
content=request.form("content")
pic=request.form("pic")
shijian=now()
if act="add" then
sql="select * from ad"
set rs=server.createObject("Adodb.recordSet")
rs.open sql,conn,1,3
rs.AddNew
rs("ad_title")=ad_title
rs("ad_link")=ad_link
rs("ad_date")=ad_date
rs("ad_pic")=pic
rs("ad_swf")=content
rs("updatetime")=shijian
rs.Update
rs.close
set rs=nothing
closeconn
response.write("<script language='javascript'>alert('添加成功!');window.location.href='ad.asp';</script>")
response.end
end if
if act="update" and IsNumeric(id) then
sql="select * from ad where id="&id
set rs=server.createObject("Adodb.recordSet")
rs.open sql,conn,1,3
rs("ad_title")=ad_title
rs("ad_link")=ad_link
rs("ad_date")=ad_date
rs("ad_pic")=ad_pic
rs("ad_swf")=ad_swf
rs("updatetime")=now()
rs.Update
rs.close
set rs=nothing
closeconn
response.write("<script language='javascript'>alert('修改成功!');window.location.href='ad.asp';</script>")
response.end
end if
if act="del" then
ad_id=request.form("ad_id")
if ad_id="" then response.redirect "ad.asp"
sql="delete * from ad where id in("&ad_id&")"
conn.execute(sql)
response.redirect "ad.asp"
response.end
end if
response.write("<script language='javascript'>alert('参数错误,请返回!');window.location.href='ad.asp';</script>")
response.end
%>
添加能正常添加,但是修改以后图片就没了,我非常郁闷,现在再回头看看,原来是自己笨,这么简单的问题就不会了。只要把那个红色标记的地方换成rs("ad_pic")=pic rs("ad_swf")=content 就行了,呵呵,我好笨啊。