Stored Procedure return value

Results 1 to 2 of 2

Thread: Stored Procedure return value

  1. #1
    roop Guest

    Default Stored Procedure return value

    How do i trap the return value (integer) from the stored procedure in my asp page<BR>thanks<BR>

  2. #2
    Garth Guest

    Default RE: Stored Procedure return value

    The code shown below demonstrates how to get a return value from a stored procedure. Execute the DDL in tempdb, replace the login information with valid values and then execute the ASP.<BR><BR>Garth<BR><BR><BR><BR>--DDL<BR>CREATE TABLE Test<BR>(<BR> Column1 int IDENTITY PRIMARY KEY,<BR> Column2 varchar(10)<BR> )<BR>go<BR>CREATE PROCEDURE ps_Test_INSERT<BR>@Column2 varchar(10),<BR>@ReturnValue int OUTPUT<BR>AS<BR>INSERT test VALUES (@Column2)<BR>SELECT @ReturnValue = @@IDENTITY<BR><BR><BR>--ASP<BR>&#060;!--#include file=""--&#062;<BR>&#060;%<BR> Column2 = "Test Data"<BR><BR> Set objConn = server.CreateObject("ADODB.Connection")<BR><BR> REM DSN-Less ODBC<BR> REM objConn.Open "Driver={SQL Server};Server=ACE;Database=tempdb;Uid=sa;Pwd="<BR ><BR> REM DSN-Less OLE-DB<BR> objConn.Open "Provider=SQLOLEDB;Server=ACE;Database=tempdb;Uid= sa;Pwd="<BR><BR><BR> Set cmd1 = server.CreateObject("ADODB.Command")<BR> cmd1.ActiveConnection = objConn<BR> cmd1.CommandType = adCmdStoredProc<BR> cmd1.CommandText = "ps_Test_INSERT"<BR> cmd1.Parameters.Append cmd1.CreateParameter("Column2",adVarChar,adParamIn put,10,Column2)<BR> cmd1.Parameters.Append cmd1.CreateParameter("ReturnValue",adInteger,adPar amOutput)<BR> cmd1.Execute<BR><BR> response.write cmd1.Parameters("ReturnValue")<BR><BR> %&#062;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts