Replies Back to Article

PureUpload delete file before delete/update

Needing help
November 15, 2001 by Adam Toohey
Hi, it seems there is more to what you say that's it!!  I am sure that I am doing something wrong.  I suppose I don't really see exactly what you added to the recordset.

Is this where the location of the file being deleted is supposed to be? ImagePath = Server.MapPath("..\upload")

I followed your tutorial exactly.  I didn't add anything to the recordset.  Do I need to?  All I did with the recordset was move it to the top.

After following the tutorial this is the error I am getting.


Error Type:
ADODB.Fields (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/wilkinsons/admin/adminhouseland/delete.asp, line 94

Line 94 is this code ImagePath = ImagePath & "\" & (deletehomes.Fields.Item("image").Value)  deletehomes is the name of the recordset.

Any ideas?

Thanks in advance,

Adam Toohey

RE: Needing help
November 15, 2001 by Adam Toohey
I changed ImagePath = ImagePath & "\" & (deletehomes.Fields.Item("image").Value) to ImagePath = ImagePath & "\" & (deletehomes.Fields.Item("thumbnailpic").Value)  which is the name of the pic I am trying to delete and am now not getting any errors.  However, the file is not being deleted.

Any ideas?

I have been trying to get this working for a long time now and would really appreciate some help getting this working.

Looking forward to a response.

Adam Toohey 
RE: Needing help
November 15, 2001 by Marcellino Bommezijn

Adam,

This is the code that you actually add in the update/delete statement:

' This is where we delete the file before we delete the record!
Set File = CreateObject("Scripting.FileSystemObject")

ImagePath = Server.MapPath("..\upload")
ImagePath = ImagePath & "\" & (rsNews.Fields.Item("image").Value)

' check if file exists and if true delete the file
If fileExists(ImagePath) Then
File.DeleteFile(ImagePath)
End If

Of course you have to rename your own recordset and corresponding database fields. The database field "image" is just an example. But you already solved that one.

Now you only have to determine what the relative path is to your directory where the image/file resides. The path ("..\upload") is also an example of what it could be. So depending on your location and name of that directory in your root in could be different. For example ("..\..\images") or ("..\files"). 

Marcellino

RE: RE: Needing help
November 15, 2001 by Adam Toohey

Hi Marcellino,

I have done all of this and still the file isn't being deleted.  I am sure there is something easy that I haven't done.  This is the code I have included in my page..... 
<%
Function newFileSystemObject()
set newfilesystemobject="Server".CreateObject("Scripting.FileSystemObject")
End Function
%>
<%
Function fileExists(aFileSpec)
fileExists=newFileSystemObject.FileExists(aFileSpec)
End Function
%>
<%
' *** Delete Record: construct a sql delete statement and execute it

If (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  ' create the sql delete statement
  MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId

  If (Not MM_abortEdit) Then
    ' execute the delete
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
' This is where we delete the file before we delete the record!
Set File = CreateObject("Scripting.FileSystemObject")
ImagePath = Server.MapPath("..\..\images\jpgs\houseland")
ImagePath = ImagePath & "\" & (deletehomes.Fields.Item("thumbnailpic").Value)
' check if file exists and if true delete the file
If fileExists(ImagePath) Then
File.DeleteFile(ImagePath)
End If
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

Usually i would put a / after putting the destination in example ../../images/jpgs/houseland/  How come there is no / after the destination in your code.  I will also send you the entire page.  Maybe you can find time to have a look.

Thanks,

Adam

Check for existing file
November 16, 2001 by empty empty
What can be done to check for existing file and prompt for overwrite or not?
Needing help
November 16, 2001 by Marcellino Bommezijn

I really think your path to the file isn't correct, because i can't find any errors in your code as mentioned here.

Please verify if the path is correct, try some other combinations if you are not sure.

I must say that the page that you are running the script from is 'far' away from your actual images that you want to delete.

Try testing it by putting the image in a directory below your scriptpage, so the path is shorter (!)

Let me know !

Marcellino  

P.S.
Please sent further details/questions through email, otherwise this comment section will be stuffed with code. Thanks

Multiple deletes
November 16, 2001 by Jee Wonder

how would one go about deleting multiples.

where do i place the loop??

execute the delete/update
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection

' This is where we delete the file before we delete the record!
Set File = CreateObject("Scripting.FileSystemObject")
ImagePath = Server.MapPath("..\upload")
ImagePath = ImagePath & "\" & (rsNews.Fields.Item("image").Value)

' check if file exists and if true delete the file
If fileExists(ImagePath) Then
File.DeleteFile(ImagePath)
End If

MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

RE: Multiple deletes
November 17, 2001 by Marcellino Bommezijn

Jee,

What would you like to delete ? More records with one field that contains the image/file or one record that contains more fields with different images/files.

Marcellino

RE: Multiple deletes
November 17, 2001 by Jee Wonder

I guess i didn't describe my problem very well. I'm using checkboxes to delete multiple records that have a file attched to them. So if i check four boxes i would like four files to be deleted, but in my case allthree get deleted or atimes all of them.

<---------------------------------Start of Code------------------------------->

<%
set rsdel = Server.CreateObject("ADODB.Recordset")
rsdel.ActiveConnection = MM_tieg_STRING
rsdel.Source = "SELECT * FROM OnlineContent"
rsdel.CursorType = 0
rsdel.CursorLocation = 2
rsdel.LockType = 3
rsdel.Open()
rsdel_numRows = 0
%>
<%

dim ver
ver = request.querystring("checkbox")
if ver<>"" then

dim num

dim xide

dim whr

dim sql

whr=""

xide=split(request.querystring("checkbox"),",",-1,1)

for each num in xide

if whr<>"" then whr="whr" & " or "

whr=whr & "olid=" & num

next

do while not rsdel.eof

 Function newFileSystemObject()
 set newfilesystemobject="Server".CreateObject("Scripting.FileSystemObject")
 End Function
 
 Function fileExists(aFileSpec)
 fileExists=newFileSystemObject.FileExists(aFileSpec)
 End Function

  
' This is where we delete the file before we delete the record!
 Set File = CreateObject("Scripting.FileSystemObject")
 ImagePath = Server.MapPath("../docs")
 ImagePath = ImagePath & "\" & (rsdel.Fields.Item("Media").Value)
 ' check if file exists and if true delete the file
 If fileExists(ImagePath) Then
 File.DeleteFile(ImagePath)
 End If

rsdel.movenext

                 loop

sql="DELETE FROM OnlineContent WHERE "

sql=sql & whr %>
<!--#include file="../Connections/tieg.asp" -->

<%

set Jee = Server.CreateObject("ADODB.Command")
Jee.ActiveConnection = MM_tieg_STRING
Jee.CommandText = sql
Jee.CommandType = 1
Jee.CommandTimeout = 0
Jee.Prepared = true
Jee.Execute()

%>
<% Response.Redirect("d.asp")%>

<%
 else

Response.write "<span class=""textbold"">Missing checkbox detected  &nbsp;<a href=""javascript:history.back(1)""</span>Go back</a>"


end if

%>

<---------------------------End of Code---------------------------->

 

Multiple delete question
November 19, 2001 by Tolu Ayoola

I read a tutorial from Pierro Mattirolo, creator of UD multiple delete ext. but i still couldn't figure it out after hrs. Is is possible to implement this tutorial with the first multiple delete ext?

here's the code for the multiple delete. where do i fit in your tutorial?

<%
dim strID
strID=Request("ID")
if strID <>"" then
dim sql
sql="DELETE FROM pictures WHERE ID IN "  
sql=sql &"(" & strID & ")"
set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_pictures_STRING
Command1.CommandText = sql
Command1.Execute()
Response.Redirect("/admin/delete/pictures.asp")
 else Response.redirect("/admin/delete/pictures.asp")
 end if %>
 
 
Thanks
RE: RE: Multiple deletes
November 20, 2001 by Jee Wonder

What i want to delete is multiple records and multiple files.

hope this helps.

Hi Marcellino,
November 21, 2001 by Adam Toohey
As you know I have it all working perfectly, thanks for that.  I still need to delete multiple files though.  The tutorial you sent me to was for MySQL.  I am using access 2000.  Is there some kind of simple loop I can put after the code to delete multiple files?  I have 6 files to delete.  I AM DESPERATE :-(

Waiting patiently for your response,

Adam Toohey
RE: Hi Marcellino,
November 23, 2001 by Marcellino Bommezijn

Adam,

Hope this is what you are looking for !?

Marcellino

RE: RE: Hi Marcellino,
November 23, 2001 by Adam Toohey
Hi Marcellino,  I have played with this code for a while now, I am sure it will work.  I am just a bit confused as to where the extra code is placed and what needs to be replaced.  I have tried everything I thought would work, now my code is so messed up that I have to start again :-)  All I need to know is what needs to be replaced and what and where does the extra code go.  Thanks Marcellino, I think you are a legend for putting up with everyone not getting it right,

Looking forward to your response,

Adam
Thankyou!!
November 23, 2001 by Adam Toohey
Hi Marcellino,

I would just like to say that it is rare to receive the support and patients that Marcellino has given me to successfuly get this working.  Thankyou very much Marcellino, YOU ARE AN ABSOLUTE LEGEND!!  :-)

I hope I can help you out in some way in the future.

Thanks again, from a very happy

Adam Toohey
RE: Thankyou!!
November 29, 2001 by Jee Wonder
Care to share the code you use that works.
RE: RE: Thankyou!!
November 29, 2001 by Adam Toohey
I will try to help you in any way I can.  What's the problem?  I have done exactly what Marcellino has done above.  The only thing that I realised needed to be done to get this to work was make sure that the \ was put after the path to the file destination.  Example ImagePath = Server.MapPath("..\upload\") 

This was the only thing that was missing before which stopped it from working.  As you can see, Marcellino has now put the \ in the tutorial.  He said that it only worked for him if the \ wasn't there.  He said it was maybe something with ISS versions.  I am using IIS 5 and Access 2000.  Hope this helps.

Adam

RE: RE: Multiple deletes
December 17, 2001 by Rene Bommezijn

Dear Marcellino,

I'm missing your comments on how to delete multiple records and their related images in this discussion thread. Is it possible for you to place them again?

René

Thankyou!
January 4, 2002 by Diane Milnes

Just wanted to say a big thankyou for this excellent tutorial. I now have the multiple delete and update working and I know I couldn't have done it without your help!

An Ultradev Extension for this script would be really cool...

Diane

Make sure you can get a recordset value - over a network - passing a form value
February 21, 2002 by Harry Toews

Add <input type="hidden" name="PathFilename" value="<%= rsLoanDeleteFinal.Fields.Item("FilePath").Value %>"> to your Form area. This keeps the record current, especially if you are passing an ID value from a previous page.

Add 'Filename = Request.Form("PathFilename")' without the quotes, to your ***Declare Record Variables area.

Use 'ImagePath = ImagePath & Filename' again, without the quotes in your Delete Statement. This is the easiest way to make sure you have a current recordset value when executing the Delete statement.

I tested it and it works fine over a network with a file server ....

P.S. - don't forget to set your file permissions on the folder that you are uploading/deleting from :)

Bug found.....
March 9, 2002 by Jee Wonder

I found a bug in which when you have two file fields and one is not updated the file that's not updated gets deleted.

Any insight to this i think an IF statement requesting the form value might solve the trick.

What do you think?

Here's the solution
March 9, 2002 by Jee Wonder
 if UploadFormRequest ("image") <> "" then
   Set File = CreateObject("Scripting.FileSystemObject")
   ' This is where we delete the image before we update the image!
   ImagePath1 = Server.MapPath("../uploads/industry")
   ImagePath1 = ImagePath1 & "\" & (rsin.Fields.Item("image").Value)
   ' check if file exists and if true delete the file
   
   If fileExists(ImagePath1) Then
   File.DeleteFile(ImagePath1)
   End If
 else
  
 End if
Server.MapPath problem
March 13, 2002 by Jackie Johnston

I think Adam may be having the same problem as I am. I'm storing my filenames with the "prefix with full path" option checked. So instead of an image called "image1.jpg" I've got "uploadedfiles/images/image1.jpg"

The page I'm updating the record on is located at "uploadedfiles/update.asp" So my question is how to adjust the Server.MapPath code for this. It seems like I'd have to strip off the "uploadedfiles/images/" part somehow. Any suggestions?

Thanks.

Trying to "Update Multiple files" using the delete script
May 7, 2002 by eric scharmach

I'm using the delete script you supplied to try and replace two files.  But what happens is the old files AND the newfiles get deleted...so in the end I have an updated record with a dead link.

Below is my script:

<%
Function newFileSystemObject()
set newfilesystemobject="Server".CreateObject("Scripting.FileSystemObject")
End Function
%>


<%
Function fileExists(aFileSpec)
fileExists=newFileSystemObject.fileExists(aFileSpec)
End Function
%>


<%
' *** Update Record: (Modified for File Upload) construct a sql update statement and execute it

ImagePath1 = Server.MapPath("..\..\dn\resumes\")
ImagePath1 = ImagePath1 & "\" & (rsEmployee.Fields.Item("Resumepdf").Value)

ImagePath2 = Server.MapPath("..\..\dn\resumes\")
ImagePath2 = ImagePath2 & "\" & (rsEmployee.Fields.Item("Resumeword").Value)


Dim ImageLibrary(1)
ImageLibrary(0) = ImagePath1
ImageLibrary(1) = ImagePath2

 

If (CStr(UploadFormRequest("MM_update")) <> "" And CStr(UploadFormRequest("MM_recordId")) <> "") Then

  ' create the sql update statement
  MM_editQuery = "update " & MM_editTable & " set "
  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
    FormVal = MM_fields(i+1)
    MM_typeArray = Split(MM_columns(i+1),",")
    Delim = MM_typeArray(0)
    If (Delim = "none") Then Delim = ""
    AltVal = MM_typeArray(1)
    If (AltVal = "none") Then AltVal = ""
    EmptyVal = MM_typeArray(2)
    If (EmptyVal = "none") Then EmptyVal = ""
    If (FormVal = "") Then
      FormVal = EmptyVal
    Else
      If (AltVal <> "") Then
        FormVal = AltVal
      ElseIf (Delim = "'") Then  ' escape quotes
        FormVal = "'" & Replace(FormVal,"'","''") & "'"
      Else
        FormVal = Delim + FormVal + Delim
      End If
    End If
    If (i <> LBound(MM_fields)) Then
      MM_editQuery = MM_editQuery & ","
    End If
    MM_editQuery = MM_editQuery & MM_columns(i) & " = " & FormVal
  Next
  MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
 
  Dim aspfile, Imagepath1, ImagePath2


 

 If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection


' setup the statement
For Each aspfile In ImageLibrary
Set File = CreateObject("Scripting.FileSystemObject")
' check if file exists and if true delete the file
If fileExists(aspfile) Then
File.DeleteFile(aspfile)
End If
Next

MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

RE:Trying to "Update Multiple files" using the delete script
May 7, 2002 by eric scharmach

 I posted this line in the wrong place..FYI. This was not a fix..just a posting error

Dim aspfile, Imagepath1, ImagePath2

RE: Trying to
May 7, 2002 by eric scharmach

Got this working...but I don't know what this extra End if is needed for? If I take it out I get an error

    ' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
 
' This is where we delete the file before we delete the record!
Set File = CreateObject("Scripting.FileSystemObject")
ImagePath = Server.MapPath("..\..\dn\resumes")
ImagePath = ImagePath & "\" & (rsEmployee.Fields.Item("Resumepdf").Value)
ImagePath2 = ImagePath & "\" & (rsEmployee.Fields.Item("Resumeword").Value)
' check if file exists and if true delete the file
if UploadFormRequest ("txtUpResume") <> (rsEmployee.Fields.Item("Resumepdf").Value) then
If fileExists(ImagePath) Then
File.DeleteFile(ImagePath)
End if
if UploadFormRequest ("txtUpResumeWord") <> (rsEmployee.Fields.Item("Resumeword").Value) then
If fileExists(ImagePath2) Then
File.DeleteFile(ImagePath2)
End if
End if '? don't know what this is?????????
End if
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

MX version?
August 4, 2002 by Afendi Hamat

Has anyone got this to work in MX? I tried but I keep getting this error:

  • Error Type:
    Microsoft VBScript runtime (0x800A01A8)
    Object required: ''
    /helpdesk2/aFileDel.asp, line 86

    Line 86-ImagePath = ImagePath & "\" & (rsFileDel.Fields.Item("HDFile_Path").Value)

  • I'm using MX with SQL Server 2000. Anyone got a better luck?

    RE: MX version?
    August 4, 2002 by Marcellino Bommezijn

    This error is not due to MX.

    Object required means that it can't find the value specified - (rsFileDel.Fields.Item("HDFile_Path").Value) -

    This probably because the recordset (rsFileDel) is called after your delete statement (check), you can solve this by moving the complete recordset and associated parameter to the top of your page. 

     

    RE: RE: MX version?
    August 5, 2002 by Afendi Hamat
    BIG Thanks, that solved it. Thanks again for the prompt reply.
    Error
    June 1, 2003 by fabio nuñez

    Don't work it.

    Microsoft VBScript runtime error '800a01a8'

    Object required: ''

    /pruebas/borrar01.asp, line 86

    RE: Error
    June 1, 2003 by Marcellino Bommezijn

    Please take a look at the comment below the one you posted. It discusses the same error as you have and the solution to it.

    modify
    June 1, 2003 by fabio nuñez
    If I use it in modify record the old files don't delete??
    Using with Smart Image Processor
    June 19, 2003 by Phillip Duncan

    I modified the code to work with Smart Image Processor. I needed it to Delete the image and the Thumbnail that was created. I thought I'd post it in case anyone wants to do the same.

    Dim aspfile, Imagepath1, ImagePath2

    ImagePath1 = Server.MapPath("\what\images\")
    ImagePath1 = ImagePath1 & "\" & (rsDelete.Fields.Item("imageName").Value)

    ImagePath2 = Server.MapPath("\what\images\")
    ImagePath2 = ImagePath2 & "\" & Thumbnail("_small",(rsDelete.Fields.Item("imageName").Value))

    Dim ImageLibrary(3)
    ImageLibrary(0) = ImagePath1
    ImageLibrary(1) = ImagePath2

    The rest of it stays the same. Basically you use the multiple delete and drop it to 2 fields. One is the image and one is the Thumbnail. The first line deletes the image and the second deletes the image name that's followed by "_small"

    If you use something other than "_small" when you upload, change accordingly.

    Phillip

    www.allaboutduncan.com

    No luck!
    July 18, 2003 by Curtis Mulder

    I've moved the recordset in question to the top as suggested but still no luck.  Below is the error.

    ADODB.Field (0x800A0BCD)
    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
    /sgac/imageDelete.asp, line 149

    Line 149

    ImagePath = ImagePath & "/" (rsImageLib.Fields.Item("filename").Value)

    Please help!

    Only deletes the first record - Please HELP!
    February 16, 2004 by Peter Kutschmann

    First of all, MANY MANY thanks to Mr. Bommezijn for all your tutorials, it has helped me alot :) and I am sure many other people.

    Using your tutorial, I have created a delete multiple record page. This works perfectly.

    The problem is, all associated files must also be deleted. I have been using another one of your tutorials http://www.dmxzone.com/showDetail.asp?TypeId=2&NewsId=1938 but this script keeps deleting only the associated files of the first record that has been checked.

    Here is the code:

    <% Dim strDeleteList
    strDeleteList = Request.Form("Delete")
    %>
    <%
    Dim rsPasteventImages__MMColParam
    rsPasteventImages__MMColParam = "1"
    if (Request.Form("Delete") <> "") then rsPasteventImages__MMColParam = Request.Form("delete")
    %>
    <%
    set rsPasteventImages = Server.CreateObject("ADODB.Recordset")
    rsPasteventImages.ActiveConnection = MM_MICCdatabase_STRING
    rsPasteventImages.Source = "SELECT * FROM pasteventimages WHERE ID IN (" & strDeleteList & ")"
    rsPasteventImages.CursorType = 0
    rsPasteventImages.CursorLocation = 2
    rsPasteventImages.LockType = 3
    rsPasteventImages.Open()
    rsPasteventImages_numRows = 0
    %>

    Function newFileSystemObject()
    set newfilesystemobject="Server".CreateObject("Scripting.FileSystemObject")
    End Function

    Function fileExists(aFileSpec)
    fileExists=newFileSystemObject.fileExists(aFileSpec)
    End Function

    Dim aspfile,Imagepath1, ImagePath2

    ImagePath1 = Server.MapPath("\images\pastevents")
    ImagePath1 = ImagePath1 & "\" & (Thumbnail("_small",(rsPasteventImages.Fields.Item("image").Value)))

    ImagePath2 = Server.MapPath("\images\pastevents")
    ImagePath2 = ImagePath2 & "\" & (rsPasteventImages.Fields.Item("image").Value)

    Dim ImageLibrary(1)
    ImageLibrary(0) = ImagePath1
    ImageLibrary(1) = ImagePath2

    For Each aspfile In ImageLibrary
    Set File = CreateObject("Scripting.FileSystemObject")
    If fileExists(aspfile) Then
    File.DeleteFile(aspfile)
    End If

    set Command2 = Server.CreateObject("ADODB.Command")
    Command2.ActiveConnection = MM_MICCdatabase_STRING
    Command2.CommandText = "DELETE FROM pasteventimages  WHERE ID IN (" & strDeleteList & ") "
    Command2.CommandType = 1
    Command2.CommandTimeout = 0
    Command2.Prepared = true
    Command2.Execute()

    set Command2 = Nothing

    Response.Redirect("e_ctrpanel_pastevents_confirm.asp")

    End If

    I have put hours into rearranging this script, but I still only end up with deleting the associated files of the first file that has been checked for delete. All other checked records are deleted but their associated files are left in the server. Do we have to somehow loop the script?

    Please help!

    Works one place and doesn't in the other
    February 17, 2004 by Phillip Duncan
    I've got this working on a client server with the same host as mine, yet when I try to run it on my (same fields, different recordset name) is does not delete the images. The recordset is deleted and there are no errors given. The permissions are correct on the folder. Here's the code: WORKING SITE
    <%
    Dim rsDelete__MMColParam
    rsDelete__MMColParam = "1"
    If (Request.QueryString("prodID") <> "") Then 
      rsDelete__MMColParam = Request.QueryString("prodID")
    End If
    %>
    
    <%
    Dim rsDelete
    Dim rsDelete_numRows
    
    Set rsDelete = Server.CreateObject("ADODB.Recordset")
    rsDelete.ActiveConnection = MM_what_STRING
    rsDelete.Source = "SELECT * FROM products WHERE prodID = " + Replace(rsDelete__MMColParam, "'", "''") + ""
    rsDelete.CursorType = 0
    rsDelete.CursorLocation = 2
    rsDelete.LockType = 1
    rsDelete.Open()
    
    rsDelete_numRows = 0
    %>
    
    <%
    ' *** Edit Operations: declare variables
    
    Dim MM_editAction
    Dim MM_abortEdit
    Dim MM_editQuery
    Dim MM_editCmd
    
    Dim MM_editConnection
    Dim MM_editTable
    Dim MM_editRedirectUrl
    Dim MM_editColumn
    Dim MM_recordId
    
    Dim MM_fieldsStr
    Dim MM_columnsStr
    Dim MM_fields
    Dim MM_columns
    Dim MM_typeArray
    Dim MM_formVal
    Dim MM_delim
    Dim MM_altVal
    Dim MM_emptyVal
    Dim MM_i
    
    MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
    If (Request.QueryString <> "") Then
      MM_editAction = MM_editAction & "?" & Request.QueryString
    End If
    
    ' boolean to abort record edit
    MM_abortEdit = false
    
    ' query string to execute
    MM_editQuery = ""
    %>
    
    
    
    
    <%
    ' *** Delete Record: declare variables
    
    if (CStr(Request("MM_delete")) = "form1" And CStr(Request("MM_recordId")) <> "") Then
    
      MM_editConnection = MM_what_STRING
      MM_editTable = "products"
      MM_editColumn = "prodID"
      MM_recordId = "" + Request.Form("MM_recordId") + ""
      MM_editRedirectUrl = "menu.asp"
    
      ' append the query string to the redirect URL
      If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
        If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
          MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
        Else
          MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
        End If
      End If
      
    End If
    %>
    
    
    
    <%
    Function newFileSystemObject()
    set newFileSystemObject=Server.CreateObject("Scripting.FileSystemObject")
    End Function
    %>
    
    
    <%
    Function fileExists(aFileSpec)
    fileExists=newFileSystemObject.fileExists(aFileSpec)
    End Function
    %>
    
    
    <%
    ' *** Delete Record: construct a sql delete statement and execute it
    Dim aspfile, Imagepath1, ImagePath2, ImagePath3, ImagePath4, ImagePath5, ImagePath6, ImagePath7, ImagePath8
    
    ImagePath1 = Server.MapPath("\images\products\")
    ImagePath1 = ImagePath1 & "\" & (rsDelete.Fields.Item("imageOne").Value)
    
    ImagePath2 = Server.MapPath("\images\products\")
    ImagePath2 = ImagePath2 & "\" & Thumbnail("_small",(rsDelete.Fields.Item("imageOne").Value))
    
    ImagePath3 = Server.MapPath("\images\products\")
    ImagePath3 = ImagePath3 & "\" & (rsDelete.Fields.Item("imageTwo").Value)
    
    ImagePath4 = Server.MapPath("\images\products\")
    ImagePath4 = ImagePath4 & "\" & Thumbnail("_small",(rsDelete.Fields.Item("imageTwo").Value))
    
    ImagePath5 = Server.MapPath("\images\products\")
    ImagePath5 = ImagePath5 & "\" & (rsDelete.Fields.Item("imageThree").Value)
    
    ImagePath6 = Server.MapPath("\images\products\")
    ImagePath6 = ImagePath6 & "\" & Thumbnail("_small",(rsDelete.Fields.Item("imageThree").Value))
    
    ImagePath7 = Server.MapPath("\images\products\")
    ImagePath7 = ImagePath7 & "\" & (rsDelete.Fields.Item("cover").Value)
    
    ImagePath8 = Server.MapPath("\images\products\")
    ImagePath8 = ImagePath8 & "\" & Thumbnail("_small",(rsDelete.Fields.Item("cover").Value))
    
    Dim ImageLibrary(8)
    ImageLibrary(0) = ImagePath1
    ImageLibrary(1) = ImagePath2
    ImageLibrary(2) = ImagePath3
    ImageLibrary(3) = ImagePath4
    ImageLibrary(4) = ImagePath5
    ImageLibrary(5) = ImagePath6
    ImageLibrary(6) = ImagePath7
    ImageLibrary(7) = ImagePath8
    
    If (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then
    
      ' create the sql delete statement
      MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId
    
      If (Not MM_abortEdit) Then
        ' execute the delete
        Set MM_editCmd = Server.CreateObject("ADODB.Command")
        MM_editCmd.ActiveConnection = MM_editConnection
    	' setup the statement
    	For Each aspfile In ImageLibrary
    	Set File = CreateObject("Scripting.FileSystemObject")
    	' check if file exists and if true delete the file 
    	If fileExists(aspfile) Then
    	File.DeleteFile(aspfile)
    	End If
    	Next
    
    	MM_editCmd.CommandText = MM_editQuery
        MM_editCmd.Execute
        MM_editCmd.ActiveConnection.Close
    
        If (MM_editRedirectUrl <> "") Then
          Response.Redirect(MM_editRedirectUrl)
        End If
      End If
    
    End If
    %>
    
    
    
    
    
    NON-WORKING SITE
    <%
    Dim rsDelete__MMColParam
    rsDelete__MMColParam = "1"
    If (Request.QueryString("ID") <> "") Then 
      rsDelete__MMColParam = Request.QueryString("ID")
    End If
    %>
    <%
    Dim rsDelete
    Dim rsDelete_numRows
    
    Set rsDelete = Server.CreateObject("ADODB.Recordset")
    rsDelete.ActiveConnection = MM_allaboutduncancom_STRING
    rsDelete.Source = "SELECT * FROM vcd WHERE ID = " + Replace(rsDelete__MMColParam, "'", "''") + ""
    rsDelete.CursorType = 0
    rsDelete.CursorLocation = 2
    rsDelete.LockType = 1
    rsDelete.Open()
    
    rsDelete_numRows = 0
    %>
    
    <%
    ' *** Edit Operations: declare variables
    
    Dim MM_editAction
    Dim MM_abortEdit
    Dim MM_editQuery
    Dim MM_editCmd
    
    Dim MM_editConnection
    Dim MM_editTable
    Dim MM_editRedirectUrl
    Dim MM_editColumn
    Dim MM_recordId
    
    Dim MM_fieldsStr
    Dim MM_columnsStr
    Dim MM_fields
    Dim MM_columns
    Dim MM_typeArray
    Dim MM_formVal
    Dim MM_delim
    Dim MM_altVal
    Dim MM_emptyVal
    Dim MM_i
    
    MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
    If (Request.QueryString <> "") Then
      MM_editAction = MM_editAction & "?" & Request.QueryString
    End If
    
    ' boolean to abort record edit
    MM_abortEdit = false
    
    ' query string to execute
    MM_editQuery = ""
    %>
    
    
    
    
    <%
    ' *** Delete Record: declare variables
    
    if (CStr(Request("MM_delete")) = "form1" And CStr(Request("MM_recordId")) <> "") Then
    
      MM_editConnection = MM_allaboutduncancom_STRING
      MM_editTable = "vcd"
      MM_editColumn = "ID"
      MM_recordId = "" + Request.Form("MM_recordId") + ""
      MM_editRedirectUrl = "login_ok.asp"
    
      ' append the query string to the redirect URL
      If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
        If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
          MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
        Else
          MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
        End If
      End If
      
    End If
    %>
    
    
    
    <%
    Function newFileSystemObject()
    set newFileSystemObject=Server.CreateObject("Scripting.FileSystemObject")
    End Function
    %>
    
    
    <%
    Function fileExists(aFileSpec)
    fileExists=newFileSystemObject.fileExists(aFileSpec)
    End Function
    %>
    
    
    <%
    ' *** Delete Record: construct a sql delete statement and execute it
    Dim aspfile, Imagepath1, ImagePath2, ImagePath3, ImagePath4, ImagePath5, ImagePath6, ImagePath7, ImagePath8
    
    ImagePath1 = Server.MapPath("\images\vcd\")
    ImagePath1 = ImagePath1 & "\" & (rsDelete.Fields.Item("VCDimage").Value)
    
    ImagePath2 = Server.MapPath("\images\vcd\")
    ImagePath2 = ImagePath2 & "\" & Thumbnail("_small",(rsDelete.Fields.Item("VCDimage").Value))
    
    ImagePath3 = Server.MapPath("\images\vcd\")
    ImagePath3 = ImagePath3 & "\" & (rsDelete.Fields.Item("imageTwo").Value)
    
    ImagePath4 = Server.MapPath("\images\vcd\")
    ImagePath4 = ImagePath4 & "\" & Thumbnail("_small",(rsDelete.Fields.Item("imageTwo").Value))
    
    ImagePath5 = Server.MapPath("\images\vcd\")
    ImagePath5 = ImagePath5 & "\" & (rsDelete.Fields.Item("imageThree").Value)
    
    ImagePath6 = Server.MapPath("\images\vcd\")
    ImagePath6 = ImagePath6 & "\" & Thumbnail("_small",(rsDelete.Fields.Item("imageThree").Value))
    
    ImagePath7 = Server.MapPath("\images\vcd\")
    ImagePath7 = ImagePath7 & "\" & (rsDelete.Fields.Item("coverLink").Value)
    
    ImagePath8 = Server.MapPath("\images\vcd\")
    ImagePath8 = ImagePath8 & "\" & Thumbnail("_small",(rsDelete.Fields.Item("coverThumb").Value))
    
    Dim ImageLibrary(8)
    ImageLibrary(0) = ImagePath1
    ImageLibrary(1) = ImagePath2
    ImageLibrary(2) = ImagePath3
    ImageLibrary(3) = ImagePath4
    ImageLibrary(4) = ImagePath5
    ImageLibrary(5) = ImagePath6
    ImageLibrary(6) = ImagePath7
    ImageLibrary(7) = ImagePath8
    
    If (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then
    
      ' create the sql delete statement
      MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId
    
      If (Not MM_abortEdit) Then
        ' execute the delete
        Set MM_editCmd = Server.CreateObject("ADODB.Command")
        MM_editCmd.ActiveConnection = MM_editConnection
    	' setup the statement
    	For Each aspfile In ImageLibrary
    	Set File = CreateObject("Scripting.FileSystemObject")
    	' check if file exists and if true delete the file 
    	If fileExists(aspfile) Then
    	File.DeleteFile(aspfile)
    	End If
    	Next
    
    	MM_editCmd.CommandText = MM_editQuery
        MM_editCmd.Execute
        MM_editCmd.ActiveConnection.Close
    
        If (MM_editRedirectUrl <> "") Then
          Response.Redirect(MM_editRedirectUrl)
        End If
      End If
    
    End If
    %>
    
    
    
    
    
    Anyone see anything I'm missing. Driving me mad.
    pure delete
    November 7, 2007 by feng xiangling
    i like this
    Very neat, well done!
    June 6, 2008 by student 101

     

    Very, Very neat, well done!
    Thank you for this one.

    Glad to know there are real coders out there.

    Cheers