Stred procedure ASP

Results 1 to 2 of 2

Thread: Stred procedure ASP

  1. #1
    Join Date
    Dec 1969

    Default Stred procedure ASP

    Hi there!<BR><BR>When I´m calling the below SP from an ASP-page I don´t <BR>get anything back.<BR>This errormessage shows up instead.<BR><BR>"Item cannot be found in the collection corresponding to <BR>the requested name<BR>or ordinal."<BR><BR>ie. there is no Rs(0).<BR><BR>If I add the line "print @out" then it prints out an <BR>integer if i execute the SP from SQL Query Analyzer...<BR><BR>Anyone that can solve my problem<BR><BR>Best // TT<BR><BR><BR>// ASP - code //<BR>Sql=("sp_test3")<BR>Set Rs = Conn.Execute(Sql)<BR>UI = Rs(0)<BR>Response.write "<BR>Output: " & UI<BR><BR>// Stored Procedure //<BR>CREATE PROCEDURE [dbo].[sp_test3] AS<BR><BR>declare @out int<BR><BR>insert into tblTest<BR> (ui)<BR>VALUES (1)<BR><BR>select @out = @@IDENTITY<BR><BR>select @out<BR><BR>GO<BR><BR><BR>Ps.<BR>I have also tried these without any success:<BR>-- try nr1<BR>--set @ut = @@IDENTITY<BR>--select @ut<BR><BR>-- try nr2<BR>--set @ut = @@IDENTITY<BR>--return<BR><BR>-- try nr3<BR>--set @ut = @@IDENTITY<BR>--print @ut<BR>--return @ut<BR><BR>-- try nr4<BR>--select @ut = @@IDENTITY<BR><BR>-- try nr5<BR>--select @ut = @@IDENTITY<BR>--select @ut<BR><BR>-- try nr6<BR>--select @ut = @@IDENTITY<BR>--return<BR><BR>-- try nr7<BR>--select @ut = @@IDENTITY<BR>--return @ut<BR>.<BR>

  2. #2
    Join Date
    Dec 1969

    Default SET NOCOUNT ON

    CREATE PROCEDURE insertandreturn<BR><BR>AS<BR><BR>SET NOCOUNT ON -- stop SQL Server returning INSERT result<BR>INSERT tablename (cols) VALUES (vals);<BR>SELECT @@identity<BR><BR><BR>j<BR>

Posting Permissions

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