DCSportbikes.net  
» Help Support .NET!
DCSportbikes Premier Membership for 25$ per year. Discounts! Click here for full information.

Now available in the .NET Shop:



Get your DCSBN Gear!
» Shoutbox
Sorry, only registered users have the ability to use our real-time shoutbox to chat with other members.

Register now, it's free!
» Online Users: 563
1 members and 562 guests
davidcycle
Most users ever online was 4,519, September 2, 2015 at 03:26 AM.
Go Back   DCSportbikes.net > Non-Sportbike Forums > Non-Sportbike Chat

Reply
LinkBack Thread Tools
Any ASP experts here? I need some help with deleting records using ASP
Unread
  (#1)
Noob, 07 600rr
 
jly2k's Avatar
 
Posts: 200
Join Date: October 8, 2004
Any ASP experts here? I need some help with deleting records using ASP - June 18, 2008, 09:37 PM

So, I have an HTML form. User inputs the info, script processes the form and saves the info into an Access database.

Here's the sample: http://novasian.brinkster.net/form.html

Then I have a page that shows all the records in the database. But I want to add an option on this page where the user can delete the record. Ideally, I would want to be able to delete the record by clicking on the name.

Here's the page: http://novasian.brinkster.net/show_records.asp
This is what I have for the "show records" page:

<% @ Language="VBScript" %>
<% Option Explicit %>
<html><head>
<title>Form to database - showing records</title>
</head><body>
<%

Dim connection, recordset
Dim sSQL, sConnString

sSQL="SELECT * FROM Users_tbl"

Set connection = Server.CreateObject("ADODB.connection")
Set recordset = Server.CreateObject("ADODB.Recordset")

sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("Users.mdb")

Connection.Open sConnString

Recordset.Open sSQL, Connection

Response.Write "<p><u>To delete a record, click on a name</u></p>"
Response.Write "<blockquote>"


Do while Not recordset.eof
Response.Write recordset("name") & " , "
Response.Write recordset("email") & " , "
Response.Write recordset("comments") & "<BR>"

recordset.MoveNext
loop

Response.Write "</blockquote>"
Response.Write "<a href=form.html>Add new record?</a>"

recordset.Close
Set recordset = Nothing
connection.Close
Set connection = Nothing
%>
</body></html>


How can I pass the name as a form parameter to say a "delete_record.asp" page? I'm clueless.

Thanks!

This is the script for deleting the record:

<%@ Language="VBScript" %>
<% Option Explicit %>
<html><head>
</head><body>
<%
'declare your variables
Dim connection, sSQL, sConnString

sSQL="DELETE * FROM Members_tbl WHERE what do I put here?"

Set connection = Server.CreateObject("ADODB.connection")

sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("Users.mdb")

Connection.Open sConnString
Connection.Execute sSQL

connection.Close
Set connection = Nothing
%>
</body></html>

Last edited by jly2k; June 18, 2008 at 09:40 PM..
  Send a message via AIM to  
Reply With Quote
Unread
  (#2)
Ninja in Training....
 
roadrunner78's Avatar
 
Posts: 1,399
Join Date: June 11, 2007
Location: Virginia
June 18, 2008, 09:45 PM

You can do it the same way you add a record. Basically you want to make those variables that you used to add the record the same as the ones you are using to delete the record. Or if your entries have unique ID then you can do it that way as well.


- Craig

If you don't know go ask yo momma

'04 R1 aka "The Bastard"
  Send a message via AIM to Send a message via Yahoo to roadrunner78 Send a message via AIM to roadrunner78  
Reply With Quote
Unread
  (#3)
Noob, 07 600rr
 
jly2k's Avatar
 
Posts: 200
Join Date: October 8, 2004
June 18, 2008, 10:05 PM

It worked. Thanks!!


ADMIN - please delete post
  Send a message via AIM to  
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Powered by vBadvanced CMPS v3.2.3


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0
vBulletin Skin developed by: vBStyles.com
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 2002-2010 by DCSportbikes.net. DCSportbikes.net is owned by End of Time Studios, LLC.