Ask a Question related to ASP Database, Design and Development.
-
Fredrik/Sweden #1
multiple delete with checkboxes ?
Hi !
back again...
got this problem with multiple delete with checkboxes. when i click
the 'Delete user' link i get all users in the db listed nicely in a
table with a checkbox in front of each one. i then want to click as
many as i want and delete them from the database. this last procedure
is causing this error:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in
criteria expression.
/VS_Files/deleteUser.asp, line 19
in the errormessage, all values of the postdata are correct...
if i leave all boxes unchecked, the script works and gives me the "You
didn't select any items to delete" message.
could really need some help...goin' crazy...
code included below...
thanks...
Fredrik
---------------------------------------------------------------------------
//chooseUserToDelete.asp
<!--#Include File="Connect.asp" -->
<%
Set RS = Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection = Con
SQLstring = "SELECT [Pnr], [FirstName], [LastName] FROM [Accounts]"
RS.Open SQLstring
%>
<html>
<body bgcolor="">
<center>
<FORM METHOD="POST" ACTION="deleteUser.asp">
<table width="500" border="1" bgcolor="" cellpadding="4"
cellspacing="0">
<tr>
<td align="center" colspan="4" bgcolor="">
<font face="Arial" size="3"><b>
Choose user to delete
</b></font>
</td>
</tr>
<%
'loop through all available users & display them
WHILE NOT RS.EOF
%>
<tr>
<td width="30">
<INPUT TYPE="CHECKBOX" NAME="check" VALUE=<%=RS("Pnr")%>>
</td>
<td width="90"><%=RS("Pnr")%> </td>
<td width="150"><%=RS("FirstName")%> </td>
<td><%=RS("LastName")%> </td>
</tr>
<%
RS.MoveNext
WEND
RS.Close
Con.Close
%>
<tr>
<td colspan=4 align="right">
<input type="submit" value="Delete">
</td>
</tr>
</table>
</FORM>
</center>
</body>
</html>
----------------------------------------------------------------------
//deleteUser.asp
<!--#Include File="Connect.asp" -->
<%
Dim deleteList
deleteList = Request("check")
if deleteList = "" then
'No items to delete
Response.Write "You did not select any items to delete!"
Else
'Now, use SQL set notation to delete all the records
'specified by deleteList
Dim SQLstring
SQLstring = "DELETE FROM [Accounts] WHERE [Pnr] IN (" & deleteList &
")"
Con.Execute SQLstring //line 19
'Clean up
Con.Close
Set Con = Nothing
'confirm that the user have been deleted.
Response.Write Request("check").Count & " users were deleted..."
End If
%>
----------------------------------------------------------------------------
Fredrik/Sweden Guest
-
Checkboxes in grid/delete row not working
I copied the code for this direclty from http://www.asfusion.com/blog, but for some reason when I go to delete a row in the grid, it merely leaves... -
Please help with multiple checkboxes?
Greetings: A question on a test (form) has 2 correct answers, "ans_b" and "ans_c". In the DB, the "ans_correct" field contains both values,... -
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... -
Select multiple checkboxes
Hi all, Let's say I have a screen of fifty checkboxes in a grid style. How can I set it up so that instead of clicking each individual checkbox, a... -
Delete Multiple items with checkboxes
Hello all, I'm sorry for posting this because you probably answered this question a million times, but i didn't got my script to run yet. I'm... -
Ray at #2
Re: multiple delete with checkboxes ?
What datatype is PNR? If it is not numeric, you'll have to convert the list
from 3, 4, 9, 30 to '3', '4', '9', '30' or change the datatype in your DB.
If you want to change the deleteList to have the ''s in it, you can add
this.
deleteList = "'" & Replace(deleteList, ", ", "','") & "'"
Also, you should be using Request.FORM("check") (assuming your form is
POSTing)
Ray at work
"Fredrik/Sweden" <fredda054@hotmail.com> wrote in message
news:a501fefe.0310010740.5bc5e21e@posting.google.c om...>
> Error Type:
> Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
> [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in
> criteria expression.
> /VS_Files/deleteUser.asp, line 19
>
> deleteList = Request("check")
>
> Dim SQLstring
> SQLstring = "DELETE FROM [Accounts] WHERE [Pnr] IN (" & deleteList &
> ")"
>
> Con.Execute SQLstring //line 19
Ray at Guest
-
Fredrik/Sweden #3
Re: multiple delete with checkboxes ?
Thanks Ray ! You're the greatest ! you have helped me so much !
now that I've overcome theese obstacles, i can move on to further
development of my application, which I'm sure will generate some new
ones...=)
about the last problem...it was so obvious when i saw it. the
"Pnr"-field in the db is text. no wonder there was a 'datatype
mismatch'.
i used your code to fix it !
Thanks a lot !!!
seeya around...
Fredrik/Sweden Guest
-
Ray at #4
Re: multiple delete with checkboxes ?
My pleaseure. :]
Ray at work
"Fredrik/Sweden" <fredda054@hotmail.com> wrote in message
news:a501fefe.0310020707.340bee5@posting.google.co m...> Thanks Ray ! You're the greatest ! you have helped me so much !
> now that I've overcome theese obstacles, i can move on to further
> development of my application, which I'm sure will generate some new
> ones...=)
> about the last problem...it was so obvious when i saw it. the
> "Pnr"-field in the db is text. no wonder there was a 'datatype
> mismatch'.
> i used your code to fix it !
> Thanks a lot !!!
> seeya around...
Ray at Guest



Reply With Quote

