Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - help with delete method
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

help with delete method

 Post Reply Post Reply
Author
pnqoma View Drop Down
Newbie
Newbie


Joined: 14 October 2003
Location: United States
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote pnqoma Quote  Post ReplyReply Direct Link To This Post Topic: help with delete method
    Posted: 16 October 2003 at 8:49am

I'm trying to get my delete button to work but to no avail.My code is as follows: 

Dim Conn, ConnString  
 
 
 set ConnString = server.createobject("adodb.connection")
 conn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("forum1.mdb")&";"
 
 'Create the Connection object 
 connString.open (conn)
 
  
if request("action") = "delete" then

 sql = "DELETE* FROM messages WHERE id = '" & request("id")&"'" 
       Connstring.execute(sql)

Response.Write("<h1>The message has been deleted.</font><br>Back to <a href='forumlist.asp'>Forum</h1>")
 
Connstring.Close
end if

%>
Any suggestions??

 



Edited by pnqoma
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2003 at 9:03am

take out the "*" in the delete statement

http://www.w3schools.com/sql/sql_delete.asp

Contribute to the working anarchy we fondly call the Internet
Back to Top
vshriniwasan View Drop Down
Groupie
Groupie
Avatar

Joined: 17 December 2001
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote vshriniwasan Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2003 at 9:08am

if request("action") = "delete" then

connString.open conn, sql

Response.Write("<h1>The message has been deleted.</font><br>Back to <a href='forumlist.asp'>Forum</h1>")
 
Connstring.Close
end if

This way everything is done only if the action is delete. Other wise, well you don't even open the connection. Keep the overhead low...

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2003 at 11:56am
To add to MorningZ's comment... You are just using the Request Object which will make it very insecure, someone can just go to that page, put in a query string and delete all records one by one. Use e.g. Request.Form and catch the Referrer that noone can post from a different page.
Back to Top
pnqoma View Drop Down
Newbie
Newbie


Joined: 14 October 2003
Location: United States
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote pnqoma Quote  Post ReplyReply Direct Link To This Post Posted: 19 October 2003 at 11:16am

Thanks guyz but nothing seemed to work.I'm still getting a blank page when i click on the delete button.This is how i created the button, i don't know whether this could have any effect on the button not working.

<button style = "width:50" onclick = location.href='delete.asp'">delete</button>

so when i click it, it just takes me to the blank asp page, with no deletion occured.

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 19 October 2003 at 9:58pm

its because where in your "location.href" do you put the query paramter to run the delete?

oh wait.. you don't

here's your code

if request("action") = "delete" then

 sql = "DELETE* FROM messages WHERE id = '" & request("id")&"'" 
       Connstring.execute(sql)

Response.Write("<h1>The message has been deleted.</font><br>Back to <a href='forumlist.asp'>Forum</h1>")
 
Connstring.Close
end if

you (1) don't pass "action=delete" to get inside the if... then...  and (2) also do not pass the "id" that the SQL statement is going to use to delete the requested record

Contribute to the working anarchy we fondly call the Internet
Back to Top
pnqoma View Drop Down
Newbie
Newbie


Joined: 14 October 2003
Location: United States
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote pnqoma Quote  Post ReplyReply Direct Link To This Post Posted: 20 October 2003 at 2:28am

 

Thankz morningz

I'm in business now

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.