Squall Leonhart
11-19-2003, 07:33 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.
code:--------------------------------------------------------------------------------
<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%> </td>
<td align=center><span class="gen"><b>Description</b></span></td>
<td width=2%> </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%> </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
code:--------------------------------------------------------------------------------
<%
'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.
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.
code:--------------------------------------------------------------------------------
<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%> </td>
<td align=center><span class="gen"><b>Description</b></span></td>
<td width=2%> </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%> </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
code:--------------------------------------------------------------------------------
<%
'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.