Asp vs. Stor Proc …. return value | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Asp vs. Stor Proc …. return value

Hallo , help me please.
1.I have an asp code and I call some stored procedure.
set rssql4= connection.Execute(" sp_zapLog ‘"&naz&"’, ‘"&user&"’ ") ….. it’s correct 2.SP make something
CREATE procedure sp_zapLog
@nazBP varchar(255),@user varchar(255)
AS Declare … something..
Declare varchar(255),@vratHodn int ….there is some code If (Select object_id(@existTab)) is not null
set @vratHodn= 1 — tab exist
set @vratHodn= 0 — tab not exist
End return @vratHodn ………… it’s error command
3.Then I need return some value to asp
How can i make with returned value ? Thanks, Lubo

you need to execute the SQL in ASP using command object with output parameter variable to get the return value.
CREATE PROCEDURE sp_sel_no_authors <br />@count_authors int OUTPUT<br />AS<br />BEGIN<br /><br />SELECT @count_authors = Count(*) FROM <br />tblAuthors <br />WHERE tblAuthors.pub_Name = "Wrox"<br /><br />END<br /><br />GO<br /><br /><br />&lt;% &lt;!–#INCLUDE VIRTUAL="/include/"–&gt;<br />Dim objConn, objCmd, objParam<br />set objConn = Server.CreateObject("ADODB.Connection")<br />objConn.Open "DSN=macdb;uid=test<img src=’/community/emoticons/emotion-4.gif’ alt=’;p’ />wd=test" <br />Set objCmd = Server.CreateObject("ADODB.Command")<br />objCmd.CommandText = "sp_sel_no_authors"<br />objCmd.CommandType = adCmdStoredProc<br />objcmd.ActiveConnection = objConn <br />Set objParam = objCmd.CreateParameter ("@count_authors",adInteger,adParamOutput,4)<br />objCmd.Parameters.Append objParam<br />ObjCmd.Execute<br />&lt;HTML&gt;<br />&lt;BODY&gt;<br />No of Authors write for wrox are: &lt;%= objCmd.Parameters.("@count_authors")%&gt;<br />&lt;/BODY&gt; <br />&lt;/HTML&gt; <br /><br />from<a target="_blank" href=></a><br /><br />—————————————-<br /<a target="_blank" href=></a><br />