ASP deletes data records and deletes file pictures at the same time

Source: Internet
Author: User

Id=request ("Id")
  If id= "" Then
  Response.Write ("<script>alert" delete operation failed: Please select the information you want to delete!) '); Hitory.go ( -1);</script> ")
  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)
' Delete file by path filename
Call Dodelfile (Asavepathfilename (n))
Next
' Delete Article www.111cn.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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.