alright, i should be getting a value back in @ret (an output variable) when i run this stored procedure, but im getting a null for the parameter value after running the procedure. heres the thing, if i run the procedure under query analyzer it return the value correctly.
heres the stored procedure
now if i comment out the last select statement (the large one) i get the return value after the SqlCommand.ExecuteReader(), but i get a null if that query is run. I can put the query where @ret is set anywhere in the procedure and it will correctly report back IF the main select is commented out. The SqlParamater is set correctly (Output Direction) as far as i can tell. Whats confusing me here, and makes me think that everything i am doing is legal, is that the value will correctly be set no matter if the main select is run when testing from query analyzer. Does anyone see something wrong with the query? I'd like to be able to run this all once instead of having to get the pagecount and then run another command to update views and get posts.
Thanks for any help,
Sheriff
heres the stored procedure
Code:
CREATE PROCEDURE
Forum_GetPosts
(
@ThreadID int,
@PageNum int,
@ret int OUTPUT
)
AS
set @ret = (select (count(a.PostID) / 50) + 1 from Forum_Post a where a.ThreadID = @ThreadID)
exec Forum_UpdateViews @ThreadID
select top 50
Forum_Post.*,
Forum_User.UserName,
Forum_User.Location,
Forum_ForumGroupPostCount.PostCount,
Forum_User.RegisterDate
FROM
Forum_Post
INNER JOIN Forum_User ON Forum_Post.UserID = Forum_User.UserID
left outer join Forum_ForumGroupPostCount on Forum_User.UserID = Forum_ForumGroupPostCount.UserID
where ThreadID = @ThreadID and ( [Order] >(50 * (@PageNum -1 ))) order by [Order] asc
GO
now if i comment out the last select statement (the large one) i get the return value after the SqlCommand.ExecuteReader(), but i get a null if that query is run. I can put the query where @ret is set anywhere in the procedure and it will correctly report back IF the main select is commented out. The SqlParamater is set correctly (Output Direction) as far as i can tell. Whats confusing me here, and makes me think that everything i am doing is legal, is that the value will correctly be set no matter if the main select is run when testing from query analyzer. Does anyone see something wrong with the query? I'd like to be able to run this all once instead of having to get the pagecount and then run another command to update views and get posts.
Thanks for any help,
Sheriff