Forums

ASP

This topic is locked

Deleting Multiple Records

Posted 22 May 2006 14:53:40
1
has voted
22 May 2006 14:53:40 David Soros posted:
I'm trying to delete multiple records filtered by a session variable (CartRange) with no luck. I've tried various options on-line but can not seem to get anything to work.
The reason I'm using a CartRange is because this number is found in the 4 different tables.
Here is what I'm tring to do.
The user enters in an ending cart number (CartRange) the RecordSet is set to filter WHERE session(CartRange) <= Ordernumber. The next 4 page diplays the same, a total of the records (detailed, orders, product, customer)in that tablethat will be deleted, and the first item in that table w/repeat record set SB with only 1 record displayed (REASON is because in any of these tables there can be one record and when I display more that 1 where 1 record is present I get the EOR error). Each time a page's delete button is clicked all of the records that fit the RecordSet are deleted and then the users is redirected to the next page for deletion. Any help would be appreciated.

Replies

Replied 23 May 2006 06:52:32
23 May 2006 06:52:32 micah santos replied:
here's another sample of deleting multiple records using checkbox

DELETE_FORM.ASP
===============

<form name="DeleteChecked" method="post" action="do_delete.asp">

<%

WHILE NOT rs.EOF

%>

<input type="checkbox" name="del" value="<%=rs("ID"%>">

<%

rs.MoveNext
WEnd

rs.Close

%>

</form>


DO_DELETE.ASP
============
<%

Dim strConnect,nDel

nDel = Request.Form ("del"

If IsEmpty(nDel) or nDel = "" Then
response.redirect "delete_form.asp"

Else

strIDs = Replace(Request.Form, "&del=", ","
strIDs = Replace(strIDs, "del=", ""

strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("records.mdb" & ";"
set DoDelete = Server.CreateObject("ADODB.Command"

DoDelete.ActiveConnection = strConnect
DoDelete.CommandText = "DELETE FROM messages WHERE ID IN (" & strIDs & ""
DoDelete.CommandType = 1
DoDelete.CommandTimeout = 0
DoDelete.Prepared = true
DoDelete.Execute()

response.redirect "delete_form.asp"

End If

%>
Replied 04 Jun 2006 03:49:06
04 Jun 2006 03:49:06 cgy01 cgy01 replied:
hey micah, remember I was doing multiple update records? well i got that to work and all. but what if I want to add check boxes to each ID and have an option to either update all the goals, or delete the selected goals..

I tried adding the code that you gave and looked at some other examples online, but the forms conflict.
can you have a form inside another form?

I have:
<form name="form1" method="post">
<form name="DeleteChecked" method="post" action="do_delete.asp">
delete.check.box.here :: list goal info here::
<deleteform Button>
<submit button form 1>

but i click on delete and nothing happens

Replied 04 Jun 2006 22:42:11
04 Jun 2006 22:42:11 cgy01 cgy01 replied:
actually I was thinking I could still just use one form (the multiple update records I did before),
and have a checkbox for delete this goal
and for each one you check box it will detect that goal change
but then i need some additional code so it deletes those selected goals and not updates them

Reply to this topic