Multiple Delete of Records Part 1

Part 1 Multiple Delete of Records

This tutorial will show you how to perform a multiple delete of records in one operation.

Part 2 Multiple Update of Records

Will show you how to update multiple records in one operation on the same page.

Note:
if the recordset in the working example is empty, you will have to wait untill i have filled it again with records.

Source:
4guysfromrolla, changed for use with Macromedia Ultradev.

Multiple Delete of Records (Part1)

This tutorial will show you how to delete multiple records using the SQL feature WHERE IN.

By using this SQL statement we can identify a set of records and use them to do a operation in the database. In the first part we will handle the deletion of records.

An example of this would be:

DELETE FROM TableName
WHERE ProdID IN (5, 6, 7)

This statement would delete the records with the id's 5, 6 and 7.

Now that we know this, we are going to use a form to display the records and collect the records that we want to delete by using checkboxes.

First of all we are going to make this form based on the following table:

This is a table with links.

Step 1: Creating the recordset and the form

We will call the page Default.asp and the form would look something like this:

The checkbox will have as Dynamic Attribute the ID of the table, in this case SCAT as checked value, so the link that we check will have the unique ID of the table in it as it's value.

.

We will name this checkbox "Delete" for purposes later on.

Apply a repeated region to the records that you want to be displayed and optional you can add navigation info and links.

And of course a submit button to POST the form to the page where we will delete the selected records. We will call this page Delete.asp.

To avoid a cache page when we return from the delete page we put a NO CACHE in this page, so we will see the new recordset without refreshing the page.

Go to Step 2 >>

 

Marcellino Bommezijn

Marcellino BommezijnMarcellino Bommezijn is one of the managers at dmxzone.com. He is a contributor on the tutorials section.

Owner of Senzes Media (http://www.activecontent.nl) which provides professional services and web applications for mid-sized companies.

ActiveContent CMS is the ASP.NET Content Management solution that is used for building professional and rich-featured websites.

See All Postings From Marcellino Bommezijn >>

Comments

Example link has changed !

September 28, 2001 by Marcellino Bommezijn

Please note that the example can now be found under:

http://www.ultradev-asp.net/udzone_tutorials/multiple/delete/Default.asp

Doesnt work

October 16, 2001 by Stuart Chase

Could somebody post the code for default.asp page?  I get the following error

ADODB.Field error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/gvfforce/db/default.asp, line 106

 

It puts out the appropriate number of check boxes for the records I have, but I get that error.

RE: Doesnt work

October 17, 2001 by Marcellino Bommezijn

Your message means that your recordset isn't correct. Check if there are rsFields that don't exist in your current recordset that is defined. Also be sure that your value in the checkbox is set correct.

Problems

November 27, 2001 by Karl Degraa

Hi, I get the following error message when trying this out.

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 3.
/AdvanceStanding/UniUnitPages/MultidelUpdate.asp, line 16

  • POST Data:
    Delete=UnspElect6&Delete=hello&Delete=get&Submit=Submit
  • If I click 2 check boxes, it says that it wants 2 parameters and so forth. It posts the data across so I am at a bit of a loss.

    Any help would be appreciated.

     

    See all 23 Comments

    You must me logged in to write a comment.