Print Page | Close Window

How can I prompt for deletion of a record?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=27919
Printed Date: 29 March 2026 at 4:24pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: How can I prompt for deletion of a record?
Posted By: kennywhite
Subject: How can I prompt for deletion of a record?
Date Posted: 08 October 2009 at 4:28pm

I have a site that is used to track assets. On a details page there is a link to delete that record.

Right now it will delete the record right away. How can I prompt for comfirmation?
 
Here is the link to delete:
 
<a href="delete_entry.asp?ID=<% Response.write (rsAsset("ID"))%>">Delete This Asset</a>
 
Here is the the "delete_entry.asp" page.
 

<% 'Dimension variables
Dim adoCon          'Holds the Database Connection Object
Dim rsDeleteEntry   'Holds the recordset for the record to be deleted
Dim strSQL          'Holds the SQL query to query the database
Dim lngRecordNo     'Holds the record number to be deleted
 
'Read in the record number to be deleted
lngRecordNo = CLng(Request.QueryString("ID"))
 

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
 

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("assets.mdb")
 
'Create an ADO recordset object
Set rsDeleteEntry = Server.CreateObject("ADODB.Recordset")
 
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT assets.* FROM assets WHERE ID=" & lngRecordNo
 
 
'Set the lock type so that the record is locked by ADO when it is deleted
rsDeleteEntry.LockType = 3
 
'Open the recordset with the SQL query
rsDeleteEntry.Open strSQL, adoCon

'Delete the record from the database
rsDeleteEntry.Delete

'Reset server objects
rsDeleteEntry.Close
Set rsDeleteEntry = Nothing
Set adoCon = Nothing

'Return to the delete select page in case another record needs deleting
Response.Redirect "update_select.asp"
%>



Replies:
Posted By: WebWiz-Bruce
Date Posted: 08 October 2009 at 4:36pm
Add a javascript confirm prompt to your hyperlink:-

<a href="delete_entry.asp?ID=<% Response.write (rsAsset("ID"))%>" onclick="return confirm('Are you sure you want to delete this?')">Delete This Asset</a>



-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: kennywhite
Date Posted: 09 October 2009 at 4:57pm

Awesome! Thanks.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net