asp连接数据库代码实例(15)
发布时间:2021-06-06
发布时间:2021-06-06
asp 连接数据库代码实例
end if
if request("action")="del" then
set rs=server.createobject("adodb.recordset")
sql="select * from biao where id="&request("id")&""
rs.open sql,conn,3,2
set fileobj=server.createobject("scripting.filesystemobject")
if fileobj.FileExists(server.mappath(""&rs("picurl"))) then
fileobj.DeleteFile server.mappath(""&rs("picurl"))
end if
rs.delete
conn.close
response.write"<script language='javascript'>alert('删除成功!');location.href('?action=manage');</script>"
end if
if request("action")="delall" then
set rs=server.createobject("adodb.recordset")
sql="select * from biao"
rs.open sql,conn,3,2
set fileobj=server.createobject("scripting.filesystemobject")
i=0
do while not(rs.bof or rs.eof) and i<rs.recordcount
if fileobj.FileExists(server.mappath(""&rs("picurl"))) then'-----------("../" &rs("picurl"))) then
fileobj.DeleteFile server.mappath(""&rs("picurl"))
end if
rs.movenext
i=i+1
loop
conn.execute("delete * from biao")
conn.close
response.write"<script language='javascript'>alert('所有已成功删除!');location.href('?action=manage');</script>"
end if
if request("action")="saveedit" then
name=request.form("name")
picurl=request.form("picurl")
hits=request.form("hits")
content=request.form("content")
set rs=server.createobject("adodb.recordset")
sql="select * from biao where id="&request("id")&""
rs.open sql,conn,3,2
rs("name")=name
rs("content")=content
rs("picurl")=picurl