quote:
Originally posted by StephenD
I've got a custom table in my snitz db that I need to link to the Topics table by TOPIC_ID. How do I pass the TOPIC_ID in an INSERT INTO NEWTABLE statement .. the same time the topic or TOPIC_ID is created in post_info.asp?
Hi Stephen,
Look in post_info.asp for NewTopicID
In Snitz 3.4.05 the code looks like this:
strSql = "SELECT Max(TOPIC_ID) as NewTopicID "
strSql = strSql & " FROM " & strActivePrefix & "TOPICS "
strSql = strSql & " WHERE FORUM_ID = " & Forum_ID
strSql = strSql & " and T_AUTHOR = " & rs("MEMBER_ID")
set rs9 = my_Conn.Execute (strSql)
NewTopicID = rs9("NewTopicID")
rs9.close
set rs9 = nothing
' DEM --> Do not update forum count if topic is moderated.... Added if and end if
if Moderation = "No" then
'## Forum_SQL - Increase count of topics and replies in Forum table by 1
strSql = "UPDATE " & strTablePrefix & "FORUM "
strSql = strSql & " SET F_LAST_POST = '" & DateToStr(strForumTimeAdjust) & "'"
strSql = strSql & ", F_TOPICS = F_TOPICS + 1"
strSql = strSql & ", F_COUNT = F_COUNT + 1"
strSql = strSql & ", F_LAST_POST_AUTHOR = " & rs("MEMBER_ID") & ""
strSql = strSql & ", F_LAST_POST_TOPIC_ID = " & NewTopicID
strSql = strSql & ", F_LAST_POST_REPLY_ID = " & 0
strSql = strSql & " WHERE FORUM_ID = " & Forum_ID
my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
end if
Apply your INSERT using NewTopicID anywhere after set rs9 = nothing.
However, that recordset was created within an if/end if statement which is if MethodType = "Topic" then/end if.
Either apply your INSERT within that if/end if and somewhere after set rs9 = nothing (During testing, I would try it before the ProcessSubscriptions call since that evokes the inc_mail.asp file, which could possibly lead you down another trail), or apply it after the end if (referring to if MethodType = "Topic" then/end if statement that set rs9 = nothing is in) by using your own if MethodType = "Topic" then/end if statement just before if MethodType = "Reply" or MethodType = "ReplyQuote" or MethodType = "TopicQuote" then.
Again, I would place it above ProcessSubscriptions during testing and then do a Response.Write strSql after the my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords from the INSERT command to verify that the NewTopicID got sent to the custom table.
Cheers,
Etymon
<