Deleting checked records from a DB

Results 1 to 3 of 3

Thread: Deleting checked records from a DB

  1. #1
    J.Thompson Guest

    Default Deleting checked records from a DB

    Hello All! This might be simple for some but I've never done this before so I would love some suggestions from any one of you. I'm trying to do a simple delete checked records using ASP and an odbc datasource. You know, when you go to a site and you see check boxes next to each entry and a button at the bottom that says "Delete all checked entries". Simply put, I'd like to find out how to code that delete all checked entries feature into my asp scripts. Right now I'm just deleting each individually where ID = (blah). But I'd like to delete more than one at a time. Any help would be greatly appreciated. Thanks!

  2. #2
    Join Date
    Dec 1969

    Default RE: Deleting checked records from a DB

    You could name all the checkboxes the primary id number, and then just concatenate the string...<BR><BR>DELETE FROM blah<BR>WHERE box = lll OR box = 222<BR><BR>etc.<BR><BR>There&#039;s no other way to specify specific records to delete, I&#039;m afraid.

  3. #3
    Join Date
    Dec 1969

    Default RE: Deleting checked records from a DB

    When you create your checkboxes, give them the same name, but set their value equal to the ID of the record each supposed to represent, like so,<BR><BR>&#060;form NAME="myform" method=post&#062;<BR>&#060;input type=checkbox value=1 name=recid&#062;<BR>&#060;input type=checkbox value=2 name=recid&#062;<BR>&#060;input type=checkbox value=3 name=recid&#062;<BR>&#060;input type=checkbox value=4 name=recid&#062;<BR>&#060;input type=checkbox value=5 name=recid&#062;<BR>&#060;input type=submit value=submit&#062;<BR>&#060;/form&#062;<BR><BR>The listbox will come through the form collections and lok like this: 1,2,3,5<BR><BR>Then create you SQL like so,<BR><BR>&#060;%<BR><BR>sql = "DELETE orders WHERE order_id IN (" & request.form("recid") & ")"<BR><BR>%&#062;

Posting Permissions

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