日期:2014-05-17 浏览次数:20966 次
<!--#include file="conn.asp"--> <% Function DeleteFile(FileName) FileName=server.MapPath(FileName) '必须转换成绝对路径的 dim Fso Set Fso = CreateObject("scripting.filesystemobject") if Fso.FileExists(Filename) then '判断文件是否存在 Fso.DeleteFile filename end if Set Fso = nothing End Function %> <% Dim action action = Request.QueryString("action") Select Case action Case "delete" delete End Select Sub Delete dim news_id,rs news_id=Trim(Request("news_id")) if isnumeric(news_id) then connopen set rs=server.createobject("adodb.recordset") sql="select * from table_news where news_id=news_id" rs.open sql,conn,1,3 DeleteFile(rs("news_img")) rs.delete rs.update rs.close set rs=nothing Response.Write("新闻删除成功 ") Response.Write("<a href='BMagNews.asp'>返回新闻管理</a> <a href='BAddNews.asp'>返回新闻发布</a>") else Response.Write("新闻删除失败 ") Response.Write("<a href='BMagNews.asp'>返回新闻管理</a> <a href='BAddNews.asp'>返回新闻发布</a>") end if End Sub %>
sql="select * from table_news where news_id=news_id" rs.open sql,conn,1,3 if not rs.eof() then DeleteFile(rs("news_img")) rs.delete rs.update end if rs.close