一聚教程网:一个值得你收藏的教程网站

热门教程

asp 删除数据记录并且同时删除文件图片

时间:2022-07-02 23:00:54 编辑:袖梨 来源:一聚教程网

Id=Request("Id")
  If Id="" Then
  Response.Write("")
  Else
  Id=Split(Id,",")  
  For i=0 to UBound(Id)  
  set oRs=SerVer.CreateObject("Adodb.recordset")
  sSql = "SELECT D_SavePathFileName FROM "&data&" WHERE ID="&id(i)&""
  oRs.Open sSql, Conn, 0, 1
  If Not oRs.Eof Then
  asSavePathFileName = oRs("D_SavePathFileName")
  Else
  asSavePathFileName=""
  End If
  oRs.Close 
  Set oRs=Nothing 


Dim aSavePathFileName
if len(aSavePathFileName)>0 then
  aSavePathFileName = Split(asSavePathFileName, "|")
  Dim n
  For n = 0 To UBound(aSavePathFileName)
 ' 按路径文件名删除文件
   Call DoDelFile(aSavePathFileName(n))  
  Next  
 '删除文章 www.111com.net
   Conn.Execute("delete from Article where id="&id(i)&"")  
   Next
end if


Sub DoDelFile(sPathFile)
 'On Error Resume Next
 Dim oFSO
 Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
  if objFSO.fileExists(Server.MapPath(sPathFile)) then
   oFSO.DeleteFile(Server.MapPath(sPathFile))
 end if

 Set oFSO = Nothing
End Sub 

热门栏目