Print Page | Close Window

Adding A Topic Automatically Via SQL

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=25464
Printed Date: 03 April 2026 at 8:24pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Adding A Topic Automatically Via SQL
Posted By: Testin123
Subject: Adding A Topic Automatically Via SQL
Date 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



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


Posted By: Scotty32
Date 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 - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins

For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .


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



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