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 >>
|
Comments
Example link has changed !
Please note that the example can now be found under:
http://www.ultradev-asp.net/udzone_tutorials/multiple/delete/Default.asp
Doesnt work
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
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
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
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.
You must me logged in to write a comment.