Forums

ASP

This topic is locked

Deleting Multiple records

Posted 18 Feb 2006 04:40:20
1
has voted
18 Feb 2006 04:40:20 Javier Castro posted:
I have been trying delete multiple records using checkboxes. I used the various tutorials, but none seem to work for me. I think I have missed something, but I have gone around and around so many times today that I cannot think straight anymore, however, I was able to make it work arecord at the time. If I select various records, then I get the following error:

Microsoft JET Database Engine error '80040e14'

Syntax error (comma) in query expression 'orderID = 11, 12, 13, 14, 15'.

/stuffdev/admin/delorders.asp, line 16

--------------------------------------------------------------------------------------------
this is the code generated by DWMX

<%

if(Request.Form("del" <> "" then DeleteCommand__DelParam = Request.Form("del"

%>
<%

set DeleteCommand = Server.CreateObject("ADODB.Command"
DeleteCommand.ActiveConnection = MM_connStuff_STRING
DeleteCommand.CommandText = "DELETE FROM tblOrders WHERE orderID = " + Replace(DeleteCommand__DelParam, "'", "''" + " "
DeleteCommand.CommandType = 1
DeleteCommand.CommandTimeout = 0
DeleteCommand.Prepared = true
DeleteCommand.Execute() <!-- this is line 16 -->
%>

<% Response.Redirect("delete_orders.asp" %>

Any ideas???

Thanks,

Javier

Replies

Replied 19 Feb 2006 20:43:37
19 Feb 2006 20:43:37 Javier Castro replied:
I am glad to say that I managed to work it out on my own <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle> not really. But further digging took me to the extension required to do it. Thank goodness. I was pulling my hairs out.

Now I have another question and the closes analogy I have is:
when using your email let say Yahoo or MSN there is an option to select all the records at once using one checkbox. How can I accomplish that Using ASP? in the meantime, I'll kepp looking for a solution.

Cheers,

Javier
Replied 20 Feb 2006 18:15:04
20 Feb 2006 18:15:04 Javier Castro replied:
Ok. to my second question I received great help. this is the code that worked for me, in case any novice needs the extra hand.

Cheers,

Javier

&lt;!-- copy and paste between the head tags of your document --&gt;

&lt;script type="text/javascript"&gt;
function check(b){
var c = document.getElementsByTagName('input');
for(var i=0;i&lt;c.length;i++){
c[i].type=='checkbox'?c[i].checked=(b.value==b.defaultValue):null;
}
b.value=(b.value==b.defaultValue)?'Uncheck All':b.defaultValue;
}
&lt;/script&gt;

&lt;!-- End of code --&gt;


&lt;!-- Copy and paste on your form, where you want it to appear the button for select all checkboxes code --&gt;
&lt;p&gt;&lt;input type="button" value="Check All" onclick="check(this)"&gt; &lt;/p&gt;
&lt;!-- End of code --&gt;

Reply to this topic