Forum Moderators: open

Message Too Old, No Replies

sp with asp empty output parameters

Stored rocedure with sql server and asp classic, the output parameters alwa

         

aish1108

6:39 pm on Aug 7, 2008 (gmt 0)

10+ Year Member



I've been up all night with this one and I can't figure it out.

I'm trying to return an output parameter from a stored procedure to an ASP page.
The stored procedure works fine in query analyzer, it returns the record set and the output parameter.

When I try to access the output parameter from my web page I get nothing, (actually Empty)

Here is my stored procedure.

CREATE PROCEDURE display_comment
(
@topic_id varchar(10),
@comment_countinteger output
)
AS

SELECT author, comment, date_submitted
FROM comments
WHERE topic_id = @topic_id AND flag = 'N' AND publish_ind = 'Y'
ORDER BY date_submitted

SELECT @comment_count = @@ROWCOUNT
RETURN 0
GO

And here is my asp code:

set oConn = Server.CreateObject("ADODB.Connection")
connection = "Provider=SQLOLEDB; Data Source=; Database=; User ID=; Password="
oConn.Open connection
set command = server.CreateObject("ADODB.Command")

command.ActiveConnection = connection
command.CommandText = "display_comment"
command.CommandType = adCmdStoredProc

command.Parameters.Append command.createParameter("@topic_id",adInteger,adParamInput, ,num)
command.Parameters.Append command.createParameter("@comment_count", adInteger, adParamOutput)

Set oRs = command.Execute

comment_count= command.Parameters("@comment_count")

Response.write "Total Comments :" & comment_count

If comment_count > 2 Then

Do While Not oRs.EOF
Response.Write oRS.Fields("author") & "<br>"
Response.Write oRS.Fields("comment")

oRS.MoveNext
Loop
End If
set oRS = Nothing

I having this problem with all my stored procedures, so I know it's the way I'm handling the ADO, ASP and stored procedure that is the problem.

I realize there are other ways to return the total rows and that in this situation it would be easier to just use a return value and adParamReturnValue, but that doesn't work either and besides I would like to know what I am doing wrong.

Please help!

ZydoSEO

3:20 am on Aug 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you checked the command object after command.execute to see if it encountered errors. Perhaps the call never succeeded because you are telling your command object to pass in an INT for @topic_id yet the stored procedure is expecting a VARCHAR for topic_id. Just a guess.