Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Delete Entire Row, not just record
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Delete Entire Row, not just record

 Post Reply Post Reply
Author
jrockfl View Drop Down
Newbie
Newbie


Joined: 03 February 2003
Location: United States
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote jrockfl Quote  Post ReplyReply Direct Link To This Post Topic: Delete Entire Row, not just record
    Posted: 16 June 2003 at 2:27pm

I am working on the web wiz guestbook tutorial. When I delete an entry, it only deletes the info (name and comments) but leaves the id Not the entire row. How can I modify this so it deletes the entire row?

Here is the code

'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 tblComments.* FROM tblComments WHERE ID_no=" & lngRecordNo

'Set the lock type so that 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

Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 16 June 2003 at 6:01pm

Nice job einstein. This code probably deleted every record in your database.  you don't need to open a recordset in order to delete something, this you use the DELETE sql statement. See below,

'Your database is opened before the code sample given
'i trust. Lets assume that your database connection variable
'name is 'conn'
'DATABASE OPENED HERE
'Set our sql statement
strSQL = "DELETE FROM tblComments WHERE Id_no=" &lngRecordNo

'DELETE THE RECORD
conn.execute(strSQL)

'DONE


the statement might need some tweaking but else it should work.

Back to Top
jrockfl View Drop Down
Newbie
Newbie


Joined: 03 February 2003
Location: United States
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote jrockfl Quote  Post ReplyReply Direct Link To This Post Posted: 16 June 2003 at 7:06pm
Thank you very much! That worked.
Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 17 June 2003 at 11:26am
any day
Back to Top
karp13 View Drop Down
Groupie
Groupie
Avatar

Joined: 03 January 2002
Location: United States
Status: Offline
Points: 152
Post Options Post Options   Thanks (0) Thanks(0)   Quote karp13 Quote  Post ReplyReply Direct Link To This Post Posted: 17 June 2003 at 12:00pm
The first code sample given is what I use and it works great. It will not delete every record in the database.

The first sample is what is used in access versions of the WWG appz.
Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 17 June 2003 at 12:01pm
never use a delete statement without a WHERE clause. Without a WHERE clause it WILL delete every record in the table
Back to Top
jrockfl View Drop Down
Newbie
Newbie


Joined: 03 February 2003
Location: United States
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote jrockfl Quote  Post ReplyReply Direct Link To This Post Posted: 17 June 2003 at 10:21pm

there is a where clause in the code
strSQL = "SELECT tblComments.* FROM tblComments WHERE ID_no=" & lngRecordNo

The code you gave me worked the way i wanted...thanks Paul

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.