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.
| User Level: | Any |
|---|---|
| Product: | Dreamweaver MX, UltraDev 4 |
| Database: | SQL Server 2000 |
| Server Model: | ASP VBScript |
| Browser: | All |
|
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 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.
|
Marcellino Bommezijn
Marcellino 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.
User Reviews
Total of 23 reviewsprimary key = text
Written by jb doria on October 25, 2005cud u help me pls, wat if the primary key is not numeric e.g text thnxs God bless i wud really appreciate ur help
Code for update multiples modified SQL
Written by greg Orr on December 5, 2004I have tried a different method for multiple field updates unsuccessfully but It should work do not know why!!! <%@LANGUAGE='VBSCRIPT'%><!--#include file='Connections/patmenu.asp' --><%Response.Buffer = True 'First, we need to ...
How do you update using an apostrophe????
Written by Zeus Maverick on February 23, 2004Yowzers!! This code is great but the text field I want to update will often contain an apostrophe...which won't work with this. When I enter an apostrophe in the text field and hit the update button, I get an error due to trying to pass a single ...
How about multiple delete of files as well?
Written by Mat Burhouse on August 19, 2003Hi, great tutorial, it really helped me!I've adapted it slightly for an image gallery with an approval system - an administrator can either approve an image or delete it with checkboxes - your code for both tutorial parts is on the same page so ...
updating more than 1 field
Written by ben tilford on July 20, 2003can anyone advise on how to update more than 1 field...? cheers' ben...
demo + completed pages
Written by Marcellino Bommezijn on July 12, 2003The demo is on-line again and the completed pages (update + delete functionality) are available for download. Hope this helps everybody that had some trouble with getting this too work !
Multiple insert
Written by empty empty on December 12, 2002How would this work with multiple inserts? essentially moving data from one table to another


.






