Stored procedure great eagle, about you in the essence of the tree structure stored procedures of the content of the posts seems wrong ah, I did the experiment, can only take root posts, I changed, in Query Analyzer can, but on the page only show a part, you help to look at it?
CREATE proc Up_topiclist
@a_ForumID int, @a_intPageNo int, @a_intPageSize tinyint
As
DECLARE @m_intRecordNumber int
DECLARE @m_intStartRecord int
DECLARE @m_intRootID int
Select @m_intRecordNumber = @a_intPageSize * @a_intPageNo
Select @m_intStartRecord = @a_intPageSize * (@a_intPageNo-1) + 1
* * To meet the conditions of the number of records * *
Select "RecordCount" = count (*)
From BBS where layer=1 and ForumID = @a_ForumID
/* Output Record * *
/* First define scrollable cursor * *
SET ROWCOUNT @m_intRecordNumber
DECLARE m_curtemp Scroll cursor
For
Select ' Rootid ' =a.rootid
From BBS as a
Join Bbsuser as D on a.userid = D.[id]
where a.layer=1 and A.forumid = @a_ForumID
ORDER BY Rootid Desc, Layer, posttime desc
Open M_curtemp
Fetch absolute @m_intStartRecord from m_curtemp to @m_intRootID
while (@ @fetch_status = 0)
Begin
Select ' ID ' = A.[id],
' Title ' = A.title,
' UserName ' = D.username,
' Hits ' = a.hits,
' Face ' = A.face,
' Layer ' =a.layer,
' Contentsize ' = datalength (a.content),