Ask a Question related to Dreamweaver AppDev, Design and Development.
-
DeanoClarke #1
Deleting Multiple Records using Checkboxes
Hi
I wonder if anyone could help, I am trying to create a multiple delete page
using checkbox's and it just will not work, I keep getting the following error
message in a browser:-
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in
query expression 'PRODUCT_ID IN ()'.
/checkboxdeletepage1.asp, line 30
I have included the code, I think it is something to do with line 26
(delcom.Command.Text= "Delete......)
Help on this would be much appreciated as I now have no hair left.
Thanks
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connTrio.asp" -->
<%
if(Request("selectionbox") <> "") then delcom__RecordIDs =
Request("selectionbox")
%>
<%
Dim rs_checkbox
Dim rs_checkbox_numRows
Set rs_checkbox = Server.CreateObject("ADODB.Recordset")
rs_checkbox.ActiveConnection = MM_connTrio_STRING
rs_checkbox.Source = "SELECT * FROM COMMENTS"
rs_checkbox.CursorType = 0
rs_checkbox.CursorLocation = 2
rs_checkbox.LockType = 1
rs_checkbox.Open()
rs_checkbox_numRows = 0
%>
<%
set delcom = Server.CreateObject("ADODB.Command")
delcom.ActiveConnection = MM_connTrio_STRING
delcom.CommandText = "DELETE FROM COMMENTS WHERE PRODUCT_ID IN (" +
Replace(delcom__RecordIDs, "'", "''") + ") "
delcom.CommandType = 1
delcom.CommandTimeout = 0
delcom.Prepared = true
delcom.Execute()
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 10
Repeat1__index = 0
rs_checkbox_numRows = rs_checkbox_numRows + Repeat1__numRows
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th scope="col">ID</th>
<th scope="col">Model</th>
<th scope="col"> </th>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT rs_checkbox.EOF))
%>
<tr>
<td><%=(rs_checkbox.Fields.Item("PRODUCT_ID").Valu e)%></td>
<td><%=(rs_checkbox.Fields.Item("PRODUCT_MODEL").V alue)%></td>
<td><input name="selectionbox" type="checkbox" id="selectionbox"
value="<%=(rs_checkbox.Fields.Item("PRODUCT_ID").V alue)%>"></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs_checkbox.MoveNext()
Wend
%>
</table>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
<%
rs_checkbox.Close()
Set rs_checkbox = Nothing
%>
DeanoClarke Guest
-
delete mulitple records with checkboxes
i have a recordset with a looped region and checkboxes each checkbox has the individual record id assigned to it my questions is what SQL command... -
Deleting multiple records
Here's what I have... A table with 3 columns. Headings are (Name, Prayer Request, and Delete). A loop that goes through a Record Set and prints... -
Insert Records from checkboxes
Hi, I would like to be able to insert multiple records into a database using checkboxes. A query is used to display the checkboxes. How can... -
Update multiple records using checkboxes
Searched the NG but no luck. Im displaying records from an Access2000 db in a table. The table is within a form and each record(row) has a... -
Deleting Multiple Records selected by checkboxes
I have tried in vain after using 2 books - Prof ASP 3.0 and the compplete Reference for DWMX and about 8 different tutorial sites on the web that... -
CarlGrint #2
Re: Deleting Multiple Records using Checkboxes
A Command will run when the page loads, so you need to place an IF statement
around it and the Dim code so that it only runs when you execute the form or
other process to Delete the item/s.
I usually pass a variable such as Delete=True either in URL or from a Hidden
form field.
You also need to move the
<%
if(Request("selectionbox") <> "") then delcom__RecordIDs =
Request("selectionbox")
%>
so it is just before the COmmand Delete, that way you can use the IF statement
around them with effecting your recordset.
You will also need to aim your Form at the same page.
Originally posted by: DeanoClarke
Hi
I wonder if anyone could help, I am trying to create a multiple delete page
using checkbox's and it just will not work, I keep getting the following error
message in a browser:-
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in
query expression 'PRODUCT_ID IN ()'.
/checkboxdeletepage1.asp, line 30
I have included the code, I think it is something to do with line 26
(delcom.Command.Text= "Delete......)
Help on this would be much appreciated as I now have no hair left.
Thanks
CarlGrint Guest
-
DeanoClarke #3
Re: Deleting Multiple Records using Checkboxes
I am a complete newbie to all of the this, how do I code the If statement, variable and hidden field.
:o
DeanoClarke Guest
-
CarlGrint #4
Re: Deleting Multiple Records using Checkboxes
Heres a sample of one file I have
<% If Request("Action") = "DeleteDoc" AND Request("ContentID") <> "" Then %>
<%
if(Request("ContentID") <> "") then CmdDelDoc__varContentID =
Request("ContentID")
%>
<%
' delete document
set CmdDelDoc = Server.CreateObject("ADODB.Command")
CmdDelDoc.ActiveConnection = MM_woodford_STRING
CmdDelDoc.CommandText = "DELETE FROM website_content WHERE ContentID = " +
Replace(CmdDelDoc__varContentID, "'", "''") + " "
CmdDelDoc.CommandType = 1
CmdDelDoc.CommandTimeout = 0
CmdDelDoc.Prepared = true
CmdDelDoc.Execute()
%>
<% Response.Redirect("")%>
<% End If ' delete document %>
For your Hidden field just add
<input name="Action" type="hidden" id="Action" value="Delete" />
to your form.
Originally posted by: DeanoClarke
I am a complete newbie to all of the this, how do I code the If statement,
variable and hidden field.
:o
CarlGrint Guest
-
DeanoClarke #5
Re: Deleting Multiple Records using Checkboxes
Hello Again - Really sorry about this
I have got further although when I select something to delete and click submit
nothing happens. Here is the code:-
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connTrio.asp" -->
<%
Dim rs_checkbox
Dim rs_checkbox_numRows
Set rs_checkbox = Server.CreateObject("ADODB.Recordset")
rs_checkbox.ActiveConnection = MM_connTrio_STRING
rs_checkbox.Source = "SELECT * FROM COMMENTS"
rs_checkbox.CursorType = 0
rs_checkbox.CursorLocation = 2
rs_checkbox.LockType = 1
rs_checkbox.Open()
rs_checkbox_numRows = 0
%>
<% IF Request("action") = "DeleteDoc" AND Request ("selectionbox") <> "" Then
%>
<%
if(Request("selectionbox") <> "") then delcom__RecordIDs =
Request("selectionbox")
%>
<%
set delcom = Server.CreateObject("ADODB.Command")
delcom.ActiveConnection = MM_connTrio_STRING
delcom.CommandText = "DELETE FROM COMMENTS WHERE PRODUCT_ID IN (" +
Replace(delcom__RecordIDs, "'", "''") + ") "
delcom.CommandType = 1
delcom.CommandTimeout = 0
delcom.Prepared = true
delcom.Execute()
%>
<% Respose.Redirect("")%>
<% End If 'delete document%>
<input name="Action" type="hidden" id="Action" value="Delete"/>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 10
Repeat1__index = 0
rs_checkbox_numRows = rs_checkbox_numRows + Repeat1__numRows
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="/checkboxdeletepage1.asp">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th scope="col">ID</th>
<th scope="col">Model</th>
<th scope="col"> </th>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT rs_checkbox.EOF))
%>
<tr>
<td><%=(rs_checkbox.Fields.Item("PRODUCT_ID").Valu e)%></td>
<td><%=(rs_checkbox.Fields.Item("PRODUCT_MODEL").V alue)%></td>
<td><input name="selectionbox" type="checkbox" id="selectionbox"
value="<%=(rs_checkbox.Fields.Item("PRODUCT_ID").V alue)%>"></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs_checkbox.MoveNext()
Wend
%>
</table>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
<%
rs_checkbox.Close()
Set rs_checkbox = Nothing
%>
DeanoClarke Guest
-
CarlGrint #6
Re: Deleting Multiple Records using Checkboxes
That is because you do not have a Hidden field called Action with a Value of
DeleteDoc.
Also, the Response.Redirect("") will need a page within the "" so the code
moves you to a page once completed.
CarlGrint Guest



Reply With Quote

