Replies Back to Article

Delete Multiple Records and Associated Files

I am sorry
January 13, 2002 by Waldo Smeets
Piero, I am very sorry but I am not able to help you at the moment. I am already having a hard time keepig up with everything that's going on in our zones. And with the conference only a few weeks away I really need to set some priorities. Sorry mate...
Multiple Delete When Image Field Empty
March 26, 2002 by Paul Gee

Excellent extension, however, if I have a database full of details where some people have and some people haven't uploaded images, the delete functions seems to stop whenever it comes across an empty image field.

If I try to run it on a table where an image field is always present it works just fine.

I know this is only a Beta version, but have you any ideas how I can work around this other than re-running the delete until all the records have gone? Thanks.

RE: Multiple Delete When Image Field Empty
March 26, 2002 by Piero Mattirolo

I haven't tested this, but it should do the job.

replace the code in the corresponding block with:

<%
Do While rsDel.EOF=False
dim TempPath
TempPath=(Server.Mappath(("YourSubfolder") &"/" & rsDel("Your DB__Field__with__File__Info")))   
rsDel.Delete
if File.FileExists(TempPath)=1 then
File.DeleteFile(TempPath)
End if    
rsDel.MoveNext
Loop
rsDel.Close
Set file="Nothing"
Set rsdel="Nothing"
else Response.redirect("Redirect__page_if__no__selection__made")
end if
Response.Redirect "Redirect__page_after__delete__action"
%>

Let me know if this helps and best regards,

 

Piero Mattirolo

RE: RE: Multiple Delete When Image Field Empty
March 26, 2002 by Paul Gee

Piero,

Thanks, this does now delete all the records in the table, but as soon as it comes across an empty image field it stops deleting the rest of the associated files.

Doesn't work with JavaScript, does it?
July 12, 2002 by Paul Hirst

What needs to be done to get the script to work with Javascript?

RE: Doesn't work with JavaScript, does it?
July 12, 2002 by Piero Mattirolo

I am unfortunately inadequate for helping you with JavaScript. It would be stimulating to try but life is short and I would hate to keep you waiting:-)

Regards,

Piero

RE: Doesn't work with JavaScript, does it?
July 13, 2002 by Paul Hirst

Thanks...the problem I'm having is with the Replace command.  Apparently, vbscript & javascript handle them differently.  I've checked with MS and haven't found a satisfactory answer.  But I'll keep working on it.  If I find a good answer, I'll let you know.

Paul

RE: Doesn't work with JavaScript, does it?
July 16, 2002 by Paul Hirst

The following code works with Javascript:

<%
var strIDs = Request.QueryString.Item;
strIDs = strIDs.replace("&del=", ",");
strIDs = strIDs.replace("del=", "");

var DoDelete = Server.CreateObject("ADODB.Command");
DoDelete.ActiveConnection = MM_connCONNECTION_STRING;
DoDelete.CommandText = "DELETE FROM tbl_TABLE WHERE ID IN (" + strIDs + ")";
DoDelete.CommandType = 1;
DoDelete.CommandTimeout = 0;
DoDelete.Prepared = true;
DoDelete.Execute();
Response.Redirect("LINKEDPAGE.asp?");
%>

Thanks go to Zvika Gur-Esh, who helped me with the Javascript.

Deleting multiple records
January 2, 2003 by Dave Filchak
Any chance of anyone have this same thing but for PHP?
which subfolder?
April 2, 2003 by ema marro

Hallo!
hope someone can help.. 
Selection page shows in the browser correctly also when I
create delete.asp and add server behaviour no errors.
The only thing is that nothin happens..i submit the form,seems working
fine  but doesn't delete any record from table of accessdb..

This is the root on my local machine

C:
default.asp
selection.asp
delete.asp
\Connections
\db\preno.mdb

I put db as directory subfolder but i guess this is the problem...
What should i select as "Subfolder"??

Hope to hear from very much:-)
Ciaoo
Ema

 

RE: which subfolder?
April 2, 2003 by Piero Mattirolo

You should make sure of the following:

1) that you have created a selection page and that this is submitting one or more record numbers.  You can check this by setting the form submit method to GET and check in the URL bar what you have submitted. If this looks like

delete.asp?checkbox=23&checkbox=28

etc.

you should be all right.  But also make sure that you that you request the value of something called checkbox as string parameter.

2) the Subfolder field should point to where you have your images, or the files referenced in the database, that you want to delete, not where you have put your database. The path to your database matters for your connection only.  Actually I am wondering if you are deleting any record at all. This is the first thing you should start checking and therefore I humbly suggest that you check my tutorial on deleting multiple records:

http://www.admil.com/tutorial/multidelete.html

multiple delete
April 3, 2003 by ema marro

Thanks for reply,I overchecked your tutorial and seems I followed all steps fine,but still not working.I don't have associated files to delete apart records in a table of preno.mdb,so I really can't guess what to write in subfolder.. 

Also,in dwmx,the server behaviour shows a red '!'  ...

\\Here what i see in the browser:\\

../selection.asp?checkbox=326&checkbox=331&Submit2=Elimina

\\Here code in delete.asp\\

 <!--#include file="Connections/ultrapreno.asp" -->
<%
Response.Buffer=1
Dim strID,rsDel,File,sql
strID=Request("checkbox")
if strID <> "" then
Set File = CreateObject("Scripting.FileSystemObject")  
Set rsDel= Server.CreateObject("ADODB.Recordset")
rsDel.ActiveConnection = MM_ultrapreno_STRING
sql="SELECT * FROM reservations WHERE ID IN "
sql=sql &"(" & strID & ")"
rsDel.Source = sql
rsDel.LockType = 3
rsDel.open()
%>

<%
Do While rsDel.EOF=False
dim TempPath
TempPath=(Server.Mappath(("") &"/" & rsDel("ID")))   
rsDel.Delete
if File.FileExists(TempPath)=true then
File.DeleteFile(TempPath)      
rsDel.MoveNext
Else
response.write "Error: no file found at the address " &"<B>" & Temppath & "</B>" &". The corresponding record was deleted."
Exit Do
End if
Loop
rsDel.Close
Set file="Nothing"
Set rsdel="Nothing"
else Response.redirect("calendar.asp")
end if
Response.Redirect "selection.asp"
%>

Thanks for your patience..

Ciaoo

Ema

RE: multiple delete
April 3, 2003 by Piero Mattirolo

Well, if you have no files to delete, then this is definitely not your extension. You should use a simpler extension, that you can find on this same site and is also Macromedia Approved:

http://www.dmxzone.com/showDetail.asp?TypeId=3&NewsId=2048

I hope this helps

delete Images
February 17, 2004 by Kenny Darcy
It would be so good if I could get this working with Pure upload, thus allowing me to do a multi delete of images. I have a parent table and a child able, the parent has all product details and the child lists the images, what I need is to be able to have a choice to multi delete images before record . thanks for all you have done .


Kenny
Deleting thumbnail
October 12, 2007 by Ken Ryan
How do you also delete the thumbnail associated with the file?