Web Wiz - Green Windows Web Hosting - Celebrating 25 Years!

  New Posts New Posts RSS Feed - Batch delete of posts fails (SQL version)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Batch delete of posts fails (SQL version)

 Post Reply Post Reply
Author
IRON-HQ View Drop Down
Newbie
Newbie


Joined: 02 November 2004
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote IRON-HQ Quote  Post ReplyReply Direct Link To This Post Topic: Batch delete of posts fails (SQL version)
    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.
Back to Top
Shatz View Drop Down
Newbie
Newbie


Joined: 30 October 2004
Location: United States
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote Shatz Quote  Post ReplyReply Direct Link To This Post 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 MSDN Article which talks about the BETWEEN expression.  Good Luck.  :)

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.