Print Page | Close Window

Batch delete of posts fails (SQL version)

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=12424
Printed Date: 11 April 2026 at 1:20pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Batch delete of posts fails (SQL version)
Posted By: IRON-HQ
Subject: Batch delete of posts fails (SQL version)
Date Posted: 02 November 2004 at 6:50pm
Whenever I attempt to do a batch delete of posts, nothing happens and the result screen says zero posts have been removed.

I have a lot of posts on my forums, and I tried out numerous setting combinations on the delete post form, with no luck at all.

I re-downloaded the latest version of the code, used a file-compare utility on batch_delete_posts.asp from what is on my site versus the fresh download, and they were identical.

Has anyone else experienced this problem or actually had success batch-deleting posts?

Thanks.



Replies:
Posted By: Shatz
Date Posted: 04 November 2004 at 10:25am

Hi IRON-HQ,

It sounds as though the initial rsCommon recordset contains 0 records.  This could be the result of a malformed SQL statement.  Not sure if this is beyond the scope of your abilities or not, but I would try the following to debug it.  Add only the lines of code indicated between the dashed lines below to the /admin/batch_delete_posts.asp file:


'Initalise the strSQL variable with an SQL statement to get the topic from the database
strSQL = "SELECT " & strDbTable & "Topic.Topic_ID, " & strDbTable & "Topic.Poll_ID FROM " & strDbTable & "Topic "
If intForumID = 0 Then
 strSQL = strSQL & "WHERE " & strDbTable & "Topic.Last_entry_date < " & strDatabaseDateFunction & " - " & intNoOfDays
Else
 strSQL = strSQL & "WHERE (" & strDbTable & "Topic.Last_entry_date < " & strDatabaseDateFunction & " - " & intNoOfDays  & ") AND (" & strDbTable & "Topic.Forum_ID=" & intForumID & ")"
End If
If intPriority <> 4 Then strSQL = strSQL & " AND (" & strDbTable & "Topic.Priority=" & intPriority & ")"
strSQL = strSQL & ";"

--------------------------------------------------
' ADD THESE TWO LINES OF CODE.
' Display the resulting SQL statement.
Response.Write "strSql = " & strSql & "<br>"
' Stop ASP processing.
Response.End
--------------------------------------------------

'Query the database
rsCommon.Open strSQL, adoCon

This will cause the server to write the strSql variable to the screen and stop execution so you can look at the SQL statement that is to be executed.  You can then open a view to the SQL table via SQL Enterprise Manager and try to execute the SQL statement via that interface which may provide additional debug information if there is a problem with it.  If still no success paste the SQL statement in to a post here so we can have a look at it.  Also, visually confirm that the Last_Entry_Date field in the Topic table got created as a date data type.

When I'm having trouble with SQL execution, I use the above method and then go to either Access or SQL Enterprise Manager and sort the data to visually confirm that there are records that should be getting deleted.  If there are, then something's wrong with the SQL statement.

I'm not a SQL expert but I have found in some instances that if I use the BETWEEN expression instead of the explicit <> operators, I have a greater degree of success in testing date ranges.  Here's an http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ba-bz_7o6m.asp - MSDN Article which talks about the BETWEEN expression.  Good Luck.  :)



-------------
Take Care,
Shatz
Pro Racing Series Developer/Administrator
http://www.ProRacingSeries.com - http://www.ProRacingSeries.com



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