Replies Back to Article

Delete file before deleting record

Nice
April 21, 2001 by Leon Radley
Thanks alot, just saved me a lot of hassel, you the man ;P
Thank You
April 21, 2001 by Max Loddo

Paul,

Thanks a lot. Great tip to complete Petrov's ASP FileUpload. Now uploading and managing files on the server have become easy tasks.

Keep up the good work!

Max

deleting multipe images
April 26, 2001 by Leon Radley
how would i do to delete multiple images?
RE: deleting multipe images
April 26, 2001 by Paul Keur

Hello Leon,

Using the sample code:

  Set File = CreateObject("Scripting.FileSystemObject")
      
ImagePath = Server.MapPath("images\")
      ImagePath = ImagePath & "\" & (rsDelete.Fields.Item("filename").Value)

      File.DeleteFile(ImagePath)

You could do a simple basic solution:

  Set File = CreateObject("Scripting.FileSystemObject")
      
ImagePath = Server.MapPath("images\")
      ImagePath = ImagePath & "\" & (rsDelete.Fields.Item("filename1").Value)

      File.DeleteFile(ImagePath)

      ImagePath = ImagePath & "\" & (rsDelete.Fields.Item("filename2").Value)
      File.DeleteFile(ImagePath)

Or you can use a 'FOR NEXT' loop where you add a variable to the filename which is a much nicer solution.

I am making an extension for this which will work with the 'PureAspUpload' from George Petrov. One of the features will be the option to select between single or multiple deletion.

Happy Coding!

Paul Keur

Errors
May 12, 2001 by Leon Radley
If the file is not found I get a filenotfound error is there a way to continue with the deletion of the next file and then the record?
RE: Errors
May 16, 2001 by Paul Keur

Hello Leon,

You can check if a file exists before the delete action.  Take a look at the following code.

Happy Coding!

Paul Keur.

' Add FileSystemObject to newFileSystemObject
<%
Function newFileSystemObject()
  set newfilesystemobject="Server".CreateObject("Scripting.FileSystemObject")
End Function
%>
' Create a function to check if the file you want to delete exists.
<%
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")
 Set File = CreateObject("Scripting.FileSystemObject")
    MM_editCmd.ActiveConnection = MM_editConnection
 ' This is where we delete the file before we delete the record!
 ImagePath = Server.MapPath("images\")
 ImagePath = ImagePath & "\" & (rsDelete.Fields.Item("filename").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

End If
%>

not deleting file
May 16, 2001 by Mark Davies

The file isn't deleteing so what i did is replace
File.DeleteFile(ImagePath) ...with
Response.Write ImagePath

now this just outputs the image path, but when it outputs the path it doesn't specify the file name but just the directory
C:\Inetpub\wwwroot\Admin\EmployeePhotos

Is this right?, I dont understand whats happening, i've done exactly as the instructions said

This is the code i have inserted
 Set File = CreateObject("Scripting.FileSystemObject")
 ImagePath = Server.MapPath("..\EmployeePhotos\")
 ImagePath = ImagePath & "\" & (Recordset1.Fields.Item("Photo").Value)
 'File.DeleteFile(ImagePath)
 Response.Write ImagePath

...and i've commented out the redirect line so i get to see the output
the Field in the Access DB is called Photo

PLEASE HELP

RE: not deleting file
May 16, 2001 by Paul Keur

Hello Mark,

Send me your asp and i'll see what i can do for you okay?

Happy Coding!

Object_required:_'rsDelete'
May 19, 2001 by Giovanni Day

I have a record set "rsdelete" and a deleterecord server behavior, I then add the code you have and I get this error "Object_required:_'rsDelete'". The error shows up in the server logs.  I have done a response.write and the file path is correct for the file. Thanks for your help..

 

Giovanni

File.DeleteFile(ImagePath)
May 23, 2001 by Julio julio

My problem is with: File.DeleteFile(ImagePath)
My computer seems to stay in some kind of loop and it never finishes executing the script.

Also why are you using imagepath with small letters in the if statement:
If fileExists(imagepath) Then

Set File = CreateObject("Scripting.FileSystemObject")
ImagePath = Server.MapPath("images\")
ImagePath = ImagePath + "\" + RsDestino.Fields.Item("foto").Value
'File.DeleteFile(ImagePath)
'Response.Write ImagePath
' check if file exists and if true delete the file
If fileExists(imagepath) Then
 File.DeleteFile(ImagePath)
 'Response.Write ImagePath
End if

RE: Object_required:_'rsDelete'
May 25, 2001 by Harry Toews

I am having similar issues with the script. It somehow seems to not be picking up the File Name to be deleted, .... even though the RecordSet contains it from the select.

If I replace the recordset with the filename and extension, ..... it deletes the file. It may have something to do with how the recordset picks up the values from the Detail page (based on parameter ID passed)....

It looks pretty straightforward .... but I still can't get it to work for me :-(

RE: Object_required:_'rsDelete'
May 25, 2001 by Harry Toews

I have found that if you are passing the Primary ID parameter from the Search Results Page to the Delete Page using a single filter (Primary ID) .... the form that sends the actual delete command only contains that single ID string (and not the column of the actual file ID).

This is what I did to get around it....
1). Add <input type="hidden" name="FileLinkID" value="<%= rsDeleteData.Fields.Item("FileLink").Value %>"> to your form as one of the fields (it has already been picked up by the recordset).

2). Use ... FilePath = FilePath & "\" & (Request("FileLinkID")) . This will pick up the hidden field passed via the form and delete the file from the folder as well as the record from the database....

3). Bob's your Uncle .... :-)

Similarly, you can use the (Request("FileLinkID")) in the code provided later in the user posts to check if the file exists.

I don't know the details of how others got the original code to work. They must have passed multiple parameters via URL ... or .... perhaps used "Form" to pass the parameters. I am not sure exactly on how UltraDev passes these from page to page yet :-?

Hope this helps....

RE: New Problem
June 2, 2001 by Phil Shevlin

I had same problem. Thanks Harry - it worked great!

However, I have a new one. "File not found"  I am sure my problem is with my Server.MapPath. (I always semm to have problems with it.)

My code...

    ImagePath = Server.MapPath("photos\")
    ImagePath = ImagePath & "\" & (Request("FileLinkID"))

The absolute path to my image sub-dir is d:/html/users/domainName/html/photos

The absolute path to my delete file sub-dir is d:/html/users/domainName/html/_private

Why doesn't the above code work?

RE: RE: New Problem
June 5, 2001 by Harry Toews

In your MapPath ......you have:-----------
ImagePath = Server.MapPath("photos\")
ImagePath = ImagePath & "\" & (Request("FileLinkID"))

Shouldn't it be ("\photos") since you are adding the backslash to it in the next line anyways?? and MapPath returns "C:\path\to\directory" ??

This is assuming that the photos directory is located in your root directory where the MapPath will point to.

You could also try hardcoding the path to get to the image directory to test functionality. That depends on whether your ISP moves things around on the server.

RE: New Problem
June 11, 2001 by Phil Shevlin
Worked Great!  Thanks!!
RE: RE: New Problem
June 15, 2001 by greg kopp

I can't write english  (i'm a frog) so i think it's your solution :

    Set File = CreateObject("Scripting.FileSystemObject")
      ImagePath = Server.MapPath("photos\")
     ImagePathe = ImagePath & "\" & (Request("FileLinkID"))
    File.DeleteFile(ImagePathe)
   'Response.Write (ImagePathe)

nice coding

Demo of the delete file function.
June 18, 2001 by Paul Keur

Hello to you all,

I've made an example program for those of you who wants to know how to get the function working. Just email me and i will send it to you.

Please forgive me that i am not able to answer all of your questions right away, i am a very busy guy and i whish i had more time to help you all.

Keep a look out in the extension dir because i am finished with the extension for this and will post it in the beta section for testing first.

Happy Coding!

Paul Keur

RE: Demo of the delete file function.
June 18, 2001 by Waldo Smeets
The demo application is now added to the tutorial. You can download it here.
RE: RE: deleting multipe images
June 24, 2001 by agoes Setiawan

Dear Mr. Paul,

I've try to delete file before delete records. There's 2 file field store on my database. how can i delete both of them.

This's my code:


ImagePath = Server.MapPath("images\")
ImagePath = ImagePath & "\" & (Request("FileLinkID"))
File.DeleteFile(ImagePath)
ImagePath = ImagePath & "\" & (Request("FileLinkID1")) 
File.DeleteFile(ImagePath)

and on the form tag:

  <input type="hidden" name="FileLinkID" value="<%= RsInsert.Fields.Item("SmallImage").Value %>">
  <input type="hidden" name="FileLinkID1" value="<%= RsInsert.Fields.Item("BigImage").Value %>">

 

Thanks

Error Deleting Multiple Image
June 25, 2001 by agoes Setiawan

Dear Mr. Paul,

I've try to delete file before delete records. There's 2 file field store on my database. how I can delete both of them.

This's my code:

Set File = CreateObject("Scripting.FileSystemObject")
ImagePath = Server.MapPath("images\")
ImagePath = ImagePath & "\" & (Request("FileLinkID"))

File.DeleteFile(ImagePath)
ImagePath = ImagePath & "\" & (Request("FileLinkID1")) 
File.DeleteFile(ImagePath)

and on the form tag:

  <input type="hidden" name="FileLinkID" value="<%= RsDelete.Fields.Item("SmallImage").Value %>">
  <input type="hidden" name="FileLinkID1" value="<%= RsDelete.Fields.Item("BigImage").Value %>">

 

Thanks

RE: Error Deleting Multiple Image
June 25, 2001 by Waldo Smeets

Try this:

Set File = CreateObject("Scripting.FileSystemObject")
FolderPath = Server.MapPath("images\")
ImagePath = FolderPath & "\" & (Request("FileLinkID"))

File.DeleteFile(ImagePath)
ImagePath = FolderPath & "\" & (Request("FileLinkID1")) 
File.DeleteFile(ImagePath)

I think that it does the job, but I have not tried it :-)

RE: File.DeleteFile(ImagePath)
June 25, 2001 by AaRoN Cardenas
i'm experiencing the same problem.
RE: RE: File.DeleteFile(ImagePath)
June 26, 2001 by Julio julio
I have tried every way I could think to make that work and could never make it happen. How toset up security measures might be a problem. But I've tried everything as far as that too. The answer evades me.
 
Let me know if you succede at it.
 
Julio
RE: File.DeleteFile(ImagePath)
June 26, 2001 by AaRoN Cardenas

this worked for me...

Are you using Norton Anti-Virus on the server?  They recently added 'Script
Blocking' (via Live Update), and this causes problems when using
delete/write operations with the FSO.  If you are, go to your NAV control
panel and uncheck Script Blocking - you will need to reboot.

HTH

Tom Steeper

http://www.webuality.com/t-cubed/

RE: RE: File.DeleteFile(ImagePath)
June 27, 2001 by Julio julio

Hello Tom.

Thank You. That was the problem. I uncheked script protection and in Norton Anti-Virus andthe script worked. Finally I know I'm not such a rock.

You are the man.

Julio

Deleting Multiple Records With No User Interaction
July 18, 2001 by Clay Dempsey

I am trying to construct a piece of code that will run whenever a default page is opened that will update all records stored in a database very reguarly, which takes the strain off of administration.  Each record has two images associated with it, thus I wish to delete the images also.  This is the code that I am trying to use, but I am receiving an error that says "Object Not Supported". 

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../Connections/eastalamed.asp" -->
<%
set rsDelete = Server.CreateObject("ADODB.Recordset")
rsDelete.ActiveConnection = MM_eastalamed_STRING
rsDelete.Source = "SELECT * FROM tblStork"
rsDelete.CursorType = 0
rsDelete.CursorLocation = 2
rsDelete.LockType = 3
rsDelete.Open()
rsDelete_numRows = 0
%>

<%
MM_editQuery = " DELETE FROM tblStork WHERE date > (now-332) "
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_eastalamed_String
Set File = CreateObject("Scripting.FileSystemObject")
FolderPath = Server.MapPath("babyphotos/")
ImagePath = FolderPath & "/" & (rsDelete.Fields.Item("picone").Value)
File.DelteFile(ImagePath)
ImagePath = FolderPath & "/" & (rsDelete.Fields.Item("pictwo").Value)
File.DelteFile(ImagePath)
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
%>

 

RE: Demo of the delete file function.
August 9, 2001 by ian bennett

i am trying to get this to work on chillisoft and getting the error message back 

Microsoft VBScript runtime error '800a01a8'

Object required: 'Recordset1'

/attachupdate.asp, line 91

this corresponds to the line

ImagePath = ImagePath & "\" & (Recordset1.Fields.Item("attachment").Value)

I don't know where i am going wrong, or is it same as alot of things, that chillisoft won't allow it

RE: RE: Error Deleting Multiple Image
September 27, 2001 by Larry Buzecky

Waldo,

Your code for multiple file delete works great if I've loaded up 2 images!  Would you mind offering the code you wrote, which is below, where it allows the second delete file to execute only if a second file exists? In my admin area, users can load either one or two files - but on the delete page, if they've only loaded one image, it still looks for a second file to delete and then balks because it can't find one.

Thank you so much for your great help!

Sincerely,

Larry B. (lbuzecky@cimanet.com)

Set File = CreateObject("Scripting.FileSystemObject")
FolderPath = Server.MapPath("images\")
ImagePath = FolderPath & "\" & (Request("FileLinkID"))

File.DeleteFile(ImagePath)
ImagePath = FolderPath & "\" & (Request("FileLinkID1")) 
File.DeleteFile(ImagePath)

RE: RE: deleting multipe images
October 2, 2001 by Larry Buzecky

Paul,

I have a situation where I need to delete two images, the first of which always exists, the second of which is an optional upload. I adapted your code for multiple file deletes and checking to see if a file exists and got this:

Set File = CreateObject("Scripting.FileSystemObject")
ImagePath = Server.MapPath("\private\AccidentAdmin")
ImagePath = ImagePath & "\" & (rsArticle.Fields.Item("doc1").Value)
If fileExists(imagepath) Then
     File.DeleteFile(ImagePath)
 End if
ImagePath = ImagePath & "\" & (rsArticle.Fields.Item("doc2").Value)
 If fileExists(imagepath) Then
     File.DeleteFile(ImagePath)
 End if

Problem is, with this code neither image ends up getting removed. Could you point me in the right direction? I would really appreciate it!

Thank you,

Larry

I know how to delete multiple images
October 31, 2001 by h sj

I know how to  delete multiple images
the first thing you must remeber is:
copy this code into your web code
<%
Function newFileSystemObject()
  set newfilesystemobject="Server".CreateObject("Scripting.FileSystemObject")
End Function
%>
<%
Function fileExists(aFileSpec)
  fileexists="newFileSystemObject".FileExists(aFileSpec)
End Function
%>
ok!
the next thing is.
modify the code like this:
If (Not MM_abortEdit) Then
    ' execute the delete
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
 MM_editCmd.CommandText = MM_editQuery
' This is where we delete the file before we delete the record!

     Set File = CreateObject("Scripting.FileSystemObject")

     ImagePath1 = Server.MapPath("\ASP\jcgs\IMAGES") 
 
     ImagePath = ImagePath1 & "\" & (Recordset1.Fields.Item("tupid").Value)

     If fileExists(ImagePath) Then

  File.DeleteFile(ImagePath)

  End If

     ImagePath = ImagePath1 & "\" & (Recordset1.Fields.Item("tupid1").Value)

  If fileExists(ImagePath) Then

   File.DeleteFile(ImagePath)

  End If       

 MM_editCmd.Execute

    MM_editCmd.ActiveConnection.Close

look it careful ImagePath1 and ImagePath ,when code File.DeleteFile(ImagePath) Execute ,ImagePath1 doesn't change .so you can use again. the code , I have tested ,it really work!
I come form china,my English is not very well .but I hope can help you! If have any question you can Email to me : hsj178@163.net. good job paul!

RE: RE: Demo of the delete file function.
November 4, 2001 by Travis Brown
Try moving the rs definition to before the delete script in your code.
Help!! Haven't seen this one before.
November 5, 2001 by Travis Brown
I'm getting this error when trying to delete. I can delete the records in the db if the file delete script is not there. Microsoft JET Database Engine error '80004005' Could not use ''; file already in use. /wynne/index.asp, line 60 Here is the offending code. I've marked line 60: If (Not MM_abortEdit) Then ' execute the delete Set MM_editCmd = Server.CreateObject("ADODB.Command") >>Line 60>> 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("uploadimages\") ImagePath = ImagePath & "\" & (rsImages.Fields.Item("wFilename").Value) File.DeleteFile(ImagePath) MM_editCmd.CommandText = MM_editQuery MM_editCmd.Execute MM_editCmd.ActiveConnection.Close
A little closer...
November 5, 2001 by Travis Brown
Regarding the post below, I think I've isolated the problem, though I don't have a solution. I'm getting this error when trying to delete a file from a directory along with the associated records in the db. I'm guessing that it is a conflict of with the Active Connections. I can delete the records if I place the rs after the delete script (because the active connection is closed?) and remove the FSO file delete (lines 61-65). Problem is, I need to define the rs before the delete to get the filename to delete. Does thes make sense to anyone? Any Help? Microsoft JET Database Engine error '80004005' Could not use ''; file already in use. /wynne/index.asp, line 60 Here is the offending code. I've marked line 60: <% set rsImages = Server.CreateObject("ADODB.Recordset") rsImages.ActiveConnection = MM_connWynne_STRING rsImages.Source = "SELECT * FROM tblPhotos ORDER BY wDate DESC" rsImages.CursorType = 0 rsImages.CursorLocation = 2 rsImages.LockType = 3 rsImages.Open() rsImages_numRows = 0 %> <% ' *** 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") >>>Line 60>>> 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("uploadimages\") ImagePath = ImagePath & "\" & (rsImages.Fields.Item("wFilename").Value) File.DeleteFile(ImagePath) 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 %> Hey, where are we going? And what's with the handbasket? Travis Brown (UD4|IIS4|NT4|ACCESS97|ASP) (UD4|IIS5|MacOS 9.2|Access2K|ASP)[red][/red][black][/black]
demo upload.asp error
November 17, 2001 by M F

I am using PWS on win98 and each time i go to use the demo file upload.asp it will not allow it. The initial page will load but it will below is the error displayed on reload - upload submited.

Anyone know how to correct this problem please email mason_fok@hotmail.com 

 

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/DeleteFile/upload.asp, line 135

800401f3

Help
December 3, 2001 by Juan Cardena

I am using PWS on win98 and each time i go to use the demo file upload.asp it will not allow it. The initial page will load but it will below is the error displayed on reload - upload submited.

Anyone know how to correct this problem please email juan@webmastersolution.com 

 

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/DeleteFile/upload.asp, line 135

800401f3

But watch out!
January 17, 2002 by Doug Maynard

I've been fooling with this too, but there's some error handling that need to be done to avoid getting yourself really cranky.

  • you've got to check that the actual physical file exists before deleting it or everything just kind of hangs
  • you also got to make sure the path to the file directory exists before you do the Server.MapPath thing - or catch the error tha FSO throws, otherwise more death by another thousand nailbites.
The extension
February 1, 2002 by Dennis van de Wijgert
When do you think that the extension wil be ready it would be very heplfull
Delete a folder
November 19, 2002 by Alexander Nikolov

I used the Pure Asp Upload 2.9,  to upload the images in a dinamic folder with name of the record ID.

To delete them Ineed to delete also the folder where they are stored. The name of any folder corispond of the Name of the Record ID. So  hou to form the Image path to delete not a single image , buth the folder where the images are stored, for the corisponding Record ID ??????

Alexander Nikolov

Delete a file
August 11, 2003 by Marc-Andre Gagnon

Hello Mark,

Check your iis if you've got 'ENABLE PARENT PATH' checked.

Sinds you are using 'ImagePath = Server.MapPath("..\fichier")' PARENT PATH must be enabled to get this line of code to work. To check if this is the case goto your iis manager then click on your website followed by right clicking on properties, then click on the tab 'HOME DIRECTORY', then click on the button 'Configuration' and the click on the tab 'APP OPTIONS'.

You can also try ImagePath = Server.MapPath("\fichier").

Happy Coding!

Paul

I used Pure ASP File Upload 2.1.3 on a windows 2000 server. When i try to delete a file a got this error message:

(Sorry for the french but i dont know the message in english)

HTTP 500 - Erreur interne de serveur
Internet Explorer

If i dont write " File.DeleteFile(ImagePath)" the code works correctly.

Set File = CreateObject("Scripting.FileSystemObject")
    ImagePath = Server.MapPath("..\fichier")
    ImagePath = ImagePath & "\" & (rsDocument.Fields.Item("nomPhysique").Value)
    If fileExists(ImagePath) Then
       File.DeleteFile(ImagePath)
    End If 

RE: Delete a file
October 16, 2003 by Chen Yachuan

During I useing these codes, I found a problem. If the file's attribute is read_only, system will report you don't have right to delete. So I made some changes to solve this problem.New codes like this:

      Set File = CreateObject("Scripting.FileSystemObject")      
      ImagePath = Server.MapPath("images\")
      ImagePath = ImagePath & "\" & (rsDelete.Fields.Item("filename").Value)
      '***New codes***
      Set Myfile = File.GetFile(ImagePath)
      Myfile.Attributes = 0 ''Set file's attribute to normal
      '**************
      File.DeleteFile(ImagePath)

Hope somebody enjoy it...

trying to pass variable table name into delete.asp
January 29, 2004 by so so

Paul, or whovever picks this up

Thank you for this script - It's just what I was looking for. I am a novice at this, but using the scripts in your demo application I have managed to pass a variable table name to the view.asp page through the URL (view.asp?table=blah). In this way the view.asp page returns the records contained in the table chosen by the user.

How can I pass that same variable through to the delete page, replacing the references to the 'upload' table in your script?

I'm totally stuck! Any help you can give would be much appreciated.

Regards

Gerard

still trying
January 29, 2004 by so so

I've been working on this all day (!) I hope someone can help me.

I have a list of tables - the user clicks on the tables which passes the table name to the view.asp page in Paul Keur's demo application using the url (view.asp?table=blah_table).

I'm trying to pick up the table name 'blah' in the delete.asp script. How can I replace the two references to the 'upload' table in the delete.asp script with the variable value (blah_table, or whatever) passed into the view page?

Please can someone help?

Many thanks

 

I think I've fixed it (?)
January 30, 2004 by so so

Passing the table name into the page 'delete.asp' via the url, I changed delete.asp by replacing the references to the table 'upload' with 'Request.QueryString("Table")' Hey Presto! it works.

This would not work yesterday - but this morning it does. the moral?: ... I have no idea what the moral is.

All I need now is a system to return a message when there are no files left in the table to delete.

Can anyone help with that?

Gerard

Working in Stored Procedures
March 23, 2004 by Simon Martin

Can anyone shed some light on how to do this in a stored procedure?

I'm happy with the WHERE IN but not got a clue on how to make my SP delete the file associated with a record as it is stored in a folder and not the database. Server.MapPath isnt accepted by SQL server

on error resume next
March 18, 2008 by student 101

Use this if there are any errors, I think.

'just in case an error occurs add this line.
 on error resume next


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