Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - How can I prompt for deletion of a record?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How can I prompt for deletion of a record?

 Post Reply Post Reply
Author
kennywhite View Drop Down
Groupie
Groupie


Joined: 26 February 2009
Location: Indy
Status: Offline
Points: 106
Post Options Post Options   Thanks (0) Thanks(0)   Quote kennywhite Quote  Post ReplyReply Direct Link To This Post Topic: How can I prompt for deletion of a record?
    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"
%>
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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>

Back to Top
kennywhite View Drop Down
Groupie
Groupie


Joined: 26 February 2009
Location: Indy
Status: Offline
Points: 106
Post Options Post Options   Thanks (0) Thanks(0)   Quote kennywhite Quote  Post ReplyReply Direct Link To This Post Posted: 09 October 2009 at 4:57pm

Awesome! Thanks.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.