Click to See Complete Forum and Search --> : Deleting multiple records from listbox


Squall Leonhart
11-17-2003, 04:52 PM
Hi, guys again

I have trouble on how to delete multiple records from listbox.
I looked around many sites but couldn't get the clear answer.
Please take a look at this code
This code managed to populate the listbox.

<form name="validform" method="post" action="updateRequest.asp?state=delete" onclick="whichchoice()" onSubmit="return dateDiff(this);">
<table ALIGN=CENTER border="0" cellpadding="3" cellspacing="1" width="100%">
<tr>
<th colspan="6" height="25"><b>Choose the items you want to delete</b></th>
</tr>
<tr>
<td width=1%>&nbsp</td>
<td align=center><span class="gen"><b>Description</b></span></td>
<td width=2%>&nbsp</td>

</tr>

<tr>
<td width=1%></td>
<td align=center><select name="myselect" style="width:300px;" size="6" multiple="multiple">
<% Do while not rsEdit.eof %>
<option value="<%=rsEdit.fields("ID")%>"><%=rsEdit.fields.item("description").value%></option>
<% rsEdit.Movenext
Loop
%>

</select></td>
<td width=2%>&nbsp</td>

</tr>
<tr><td><br></td></tr>
<tr>
<th colspan="13" height="25"><input type="submit" name="Delete" value="DELETE"></th>
</tr>
</table>
</form>


But when I click delete button and move to following page


<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsUpdate
Dim strSQL 'Holds the SQL query for the database

Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("tech_re.mdb")
Set rsUpdate = Server.CreateObject("ADODB.Recordset")
Select Case Request.Querystring("state")
Case "delete"
strSQL = "DELETE FROM tblRequest WHERE id= " & Request.Form("myselect")
adoCon.Execute(strSQL)
adoCon.Close
Set adoCon = Nothing
Response.Redirect "it_request.asp"
End Select
%>


It seems this one works only when I delete one record. But when I chose two or more records, it generate errors.
Have you guys ever encountered problem like that?
Please help me.

Squall Leonhart
11-18-2003, 02:43 PM
:) Does anyone has idea?

Squall Leonhart
11-19-2003, 11:12 AM
I can only delete one record at a time.
Is there way to delete several items at the same time?

Squall Leonhart
11-20-2003, 12:11 PM
Please help me~:)

slyfox
11-20-2003, 02:29 PM
what is the error you're receiving?

Squall Leonhart
11-21-2003, 12:36 PM
I solved problem already.
Thanks anyway.