multiple delete with checkboxes ?

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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,...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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

  4. #3

    Default 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

  5. #4

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139