Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Adding A Topic Automatically Via SQL
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Adding A Topic Automatically Via SQL

 Post Reply Post Reply
Author
Testin123 View Drop Down
Newbie
Newbie


Joined: 16 May 2007
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote Testin123 Quote  Post ReplyReply Direct Link To This Post Topic: Adding A Topic Automatically Via SQL
    Posted: 19 March 2008 at 3:37pm
I have a stored procedure to add a topic from an SQL Server stored procedure:
 
CREATE PROCEDURE DS_NewTopic
@Forum_ID int, @Subject varchar(64), @Message varchar(4096)
AS
DECLARE @NewTopicID int
DECLARE @NewThreadID int
DECLARE @Author_ID int
-- Set new topic author ID to match for 'testuser':
SET @Author_ID = 15
-- Add new topic and retrieve Topic ID:
INSERT tblTopic (Forum_ID, Subject, Priority) VALUES (@Forum_ID, @Subject, 0)
SET @NewTopicID = (SELECT MAX(Topic_ID) FROM tblTopic)
-- Add thread and retrieve Thread ID:
INSERT tblThread (Topic_ID, Author_ID, Message) VALUES (@NewTopicID, @Author_ID, @Message)
SET @NewThreadID = (SELECT MAX(Thread_ID) FROM tblThread)
-- Update Thread ID's in tblTopic
UPDATE tblTopic SET Start_Thread_ID = @NewThreadID, Last_Thread_ID = @NewThreadID WHERE Topic_ID = @NewTopicID
GO
 
This works reasonably well apart from:
1) The post is never shown as the 'Last Post'
2) If the post is the only one in a forum the post count stays at zero.
 
How can I modify the above SP to have the topic added 'correctly'?
 
Thanks
Back to Top
stevek_mcc View Drop Down
Newbie
Newbie


Joined: 11 March 2008
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek_mcc Quote  Post ReplyReply Direct Link To This Post Posted: 22 March 2008 at 2:04pm
Just a guess, but I'd imagine that the ASP code does some extra actions as well as the basic topic addition. You might be better trying to automate adding the topic by calling the actual login and post pages with a programmatic HTML client. 
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post Posted: 22 March 2008 at 2:09pm
Is this SP from V7/8?

If so then it will need updating as V9 updates more information, as V9 doesnt use SP's.

If it is your own custom work, then you are missing certen parts.

I think it maybe easier to look at the file that processes posts and work from that. Or you could just run the Post Count Sync every time you use the SP.
S2H.co.uk - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
Testin123 View Drop Down
Newbie
Newbie


Joined: 16 May 2007
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote Testin123 Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2008 at 1:40pm
The version of the forums is 9.0x
 
I'll take a look at new_post.asp
 
I guess that's the file containing the functionality I need to mirror.
 
 
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.