Print Page | Close Window

Delete Entire Row, not just 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=3583
Printed Date: 30 March 2026 at 3:03am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Delete Entire Row, not just record
Posted By: jrockfl
Subject: Delete Entire Row, not just record
Date 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




Replies:
Posted By: pmormr
Date 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.



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: jrockfl
Date Posted: 16 June 2003 at 7:06pm
Thank you very much! That worked.


Posted By: pmormr
Date Posted: 17 June 2003 at 11:26am
any day

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: karp13
Date 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.


Posted By: pmormr
Date 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

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: jrockfl
Date 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




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