Stored Proc not Outputting

Discussion in 'ASP .Net' started by David Lozzi, Dec 7, 2005.

  1. David Lozzi

    David Lozzi Guest

    Hello,

    I have a proc as displayed below. When I try to run it from ASP.NET I get an
    error.

    CREATE PROCEDURE [dbo].[cp_AddSession]
    @SID as int,
    @EID as int,
    @DID as int,
    @StartTime as varchar(10),
    @Duration as int,
    @Title as varchar(50),
    @Location as varchar(50),
    @Description as text,
    @RegForm as varchar(50),
    @SessID int OUTPUT
    AS


    INSERT INTO tblSessions
    (intEID, intDay, strStartTime, intDuration, strTitle, strDescription,
    strRoomLocation, strRegistrationForm)
    VALUES
    (@EID, @DID, @StartTime, @Duration, @Title, @Description, @Location,
    @RegForm)

    SELECT @SessID = @@IDENTITY
    GO


    Error: Procedure 'cp_AddSession' expects parameter '@SessID', which was not
    supplied.


    Thanks for the help!!

    --
    David Lozzi
    Web Applications Developer
    dlozzi@(remove-this)delphi-ts.com
     
    David Lozzi, Dec 7, 2005
    #1
    1. Advertising

  2. Did you supply the parameter in your code?

    "David Lozzi" <> wrote in message
    news:evYwLl3%...
    > Hello,
    >
    > I have a proc as displayed below. When I try to run it from ASP.NET I get
    > an error.
    >
    > CREATE PROCEDURE [dbo].[cp_AddSession]
    > @SID as int,
    > @EID as int,
    > @DID as int,
    > @StartTime as varchar(10),
    > @Duration as int,
    > @Title as varchar(50),
    > @Location as varchar(50),
    > @Description as text,
    > @RegForm as varchar(50),
    > @SessID int OUTPUT
    > AS
    >
    >
    > INSERT INTO tblSessions
    > (intEID, intDay, strStartTime, intDuration, strTitle, strDescription,
    > strRoomLocation, strRegistrationForm)
    > VALUES
    > (@EID, @DID, @StartTime, @Duration, @Title, @Description, @Location,
    > @RegForm)
    >
    > SELECT @SessID = @@IDENTITY
    > GO
    >
    >
    > Error: Procedure 'cp_AddSession' expects parameter '@SessID', which was
    > not supplied.
    >
    >
    > Thanks for the help!!
    >
    > --
    > David Lozzi
    > Web Applications Developer
    > dlozzi@(remove-this)delphi-ts.com
    >
    >
    >
    >
     
    Peter Rilling, Dec 7, 2005
    #2
    1. Advertising

  3. David Lozzi

    Karl Seguin Guest

    Also, if you are only returning 1 parameters, I'd use ExecuteScalar and
    simply select the value ala:

    object o = command.ExecuteScalar();
    if (o != null && o!= DBNull.Value)
    {
    return Int32.Parse(o);
    }

    and simply do SELECT @@IDENTITY in your stored procedure.

    This will return 1 value (the identity), which is exactly what ExecuteScalar
    is there to handle.

    On a side note, in SQL Server 2000, use SCOPE_IDENTITY() instead of
    @@IDENTITY, else you'll eventually run into trouble:
    http://weblogs.asp.net/rosherove/archive/2003/11/13/37217.aspx

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/
    http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!



    "Peter Rilling" <> wrote in message
    news:eIekt63%...
    > Did you supply the parameter in your code?
    >
    > "David Lozzi" <> wrote in message
    > news:evYwLl3%...
    >> Hello,
    >>
    >> I have a proc as displayed below. When I try to run it from ASP.NET I get
    >> an error.
    >>
    >> CREATE PROCEDURE [dbo].[cp_AddSession]
    >> @SID as int,
    >> @EID as int,
    >> @DID as int,
    >> @StartTime as varchar(10),
    >> @Duration as int,
    >> @Title as varchar(50),
    >> @Location as varchar(50),
    >> @Description as text,
    >> @RegForm as varchar(50),
    >> @SessID int OUTPUT
    >> AS
    >>
    >>
    >> INSERT INTO tblSessions
    >> (intEID, intDay, strStartTime, intDuration, strTitle, strDescription,
    >> strRoomLocation, strRegistrationForm)
    >> VALUES
    >> (@EID, @DID, @StartTime, @Duration, @Title, @Description, @Location,
    >> @RegForm)
    >>
    >> SELECT @SessID = @@IDENTITY
    >> GO
    >>
    >>
    >> Error: Procedure 'cp_AddSession' expects parameter '@SessID', which was
    >> not supplied.
    >>
    >>
    >> Thanks for the help!!
    >>
    >> --
    >> David Lozzi
    >> Web Applications Developer
    >> dlozzi@(remove-this)delphi-ts.com
    >>
    >>
    >>
    >>

    >
    >
     
    Karl Seguin, Dec 8, 2005
    #3
  4. As Peter adviced and the error says:-
    Error: Procedure 'cp_AddSession' expects parameter '@SessID', which was
    not supplied.
    You can also look at this article by Scott here at :-
    http://aspnet.4guysfromrolla.com/articles/062905-1.aspx
    For a Ref
    Patrick


    "David Lozzi" <> wrote in message
    news:evYwLl3%...
    > Hello,
    >
    > I have a proc as displayed below. When I try to run it from ASP.NET I get

    an
    > error.
    >
    > CREATE PROCEDURE [dbo].[cp_AddSession]
    > @SID as int,
    > @EID as int,
    > @DID as int,
    > @StartTime as varchar(10),
    > @Duration as int,
    > @Title as varchar(50),
    > @Location as varchar(50),
    > @Description as text,
    > @RegForm as varchar(50),
    > @SessID int OUTPUT
    > AS
    >
    >
    > INSERT INTO tblSessions
    > (intEID, intDay, strStartTime, intDuration, strTitle, strDescription,
    > strRoomLocation, strRegistrationForm)
    > VALUES
    > (@EID, @DID, @StartTime, @Duration, @Title, @Description, @Location,
    > @RegForm)
    >
    > SELECT @SessID = @@IDENTITY
    > GO
    >
    >
    > Error: Procedure 'cp_AddSession' expects parameter '@SessID', which was

    not
    > supplied.
    >
    >
    > Thanks for the help!!
    >
    > --
    > David Lozzi
    > Web Applications Developer
    > dlozzi@(remove-this)delphi-ts.com
    >
    >
    >
    >
     
    Patrick.O.Ige, Dec 8, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Collins
    Replies:
    5
    Views:
    1,978
    Jason Collins
    Aug 28, 2003
  2. David Lozzi
    Replies:
    3
    Views:
    1,949
    David Lozzi
    Jun 1, 2005
  3. NevilleDNZ
    Replies:
    9
    Views:
    452
    NevilleDNZ
    Aug 16, 2006
  4. Jean-Hugues ROBERT

    Why no Proc##[]=() ? Why no Proc##replace() ?

    Jean-Hugues ROBERT, May 1, 2004, in forum: Ruby
    Replies:
    14
    Views:
    299
    Jean-Hugues ROBERT
    May 5, 2004
  5. Minkoo Seo

    Proc vs lambda vs proc

    Minkoo Seo, Feb 4, 2007, in forum: Ruby
    Replies:
    19
    Views:
    249
    Brian Candler
    Feb 6, 2007
Loading...

Share This Page