Writing the script for the delete processor page is even easier than writing the script for the update processor. Remember, users will access this page from the master page, which you have already built, so all that remains is to add the script that deletes the record from the database.
Open admin_cp_delete_processor.asp in code view, and remove any code.
Once again, this page will contain only a short script and a redirect elsewhere, so it needs no HTML code at all.
Add the code that creates the connection.
<% Dim dbConn set dbConn = server.CreateObject("adodb.connection") dbConn.open("newland") %>
<cfquery name="delete_country" datasource="newland"> </cfquery>
Now you can insert the code that executes a SQL statement.
Add the code that deletes the record specified in the URL parameter, in the space you left in the preceding step.
In ASP (all in one line):
[View full width]dbConn.Execute("DELETE FROM tbl_country WHERE countryID=" & Request.QueryString( "countryID"))
In ColdFusion (may be on multiple lines):
DELETE FROM tbl_country WHERE countryID=#URL.countryID#
With SQL's DELETE statement, you don't have to specify each field singly, because it deletes from all fields, making it much more convenient to write. It also makes it easy to inadvertently wipe out your entire table, if you forget to specify the WHERE clause!
Add the redirection back to the master page, in the appropriate location.
In ASP, in the line above the closing %> tag:
In ColdFusion, in the line after the closing </cfquery> tag:
This returns the user to the master page, so she or he can conveniently verify that the deletion took place.
Save and upload the file. Press F12 to open admin_cp_master.asp in a browser, and delete the country you inserted earlier in the lesson.
As promised, the country disappears instantly and permanentlydon't bother trying the Back button!