Frustrating Stored Procedure Prob

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Re: Frustrating Stored Procedure Prob

    Try putting:
    set nocount on
    at the beginning of the stored procedure.

    "Andrew Paton" <andrew.paton@nospamplease.nufsaid.net> a écrit dans le message de news: [email]eYthI2MQDHA.3768@tk2msftngp13.phx.gbl[/email]...
    > I have the Simple Stored Procedure:
    >
    > CREATE PROCEDURE dbo.spCreateCart
    > AS
    > BEGIN
    > INSERT tblCart
    > VALUES (getdate())
    > SELECT @@IDENTITY as cartID
    > END
    > GO
    >
    > When i run this in stored procedure it works fine, i get my record created
    > and it returns the field i want under the alias 'cartID'
    >
    > However when i try to grab this value using the following ASP i get an 'Item
    > cannot be found in the collection corresponding to the requested name or
    > ordinal.' Error.
    >
    > SQL = "EXEC dbo.spCreateCart"
    > rsCreateCart = conn.execute(SQL)
    >
    > cartID = rsCreateCart("cartID")
    > response.write cartID
    >
    > I know that my connection is fine - since it works with other sections of
    > the script. And i have checked field names etc. This one really has me
    > stumped. Does anyone have any ideas?
    >
    > Thankyou
    >
    >
    >
    Guest

  2. Similar Questions and Discussions

    1. Stored Procedure
      EXEC master..xp_cmdshell 'cscript c:\path\file.vbs' EXEC master..xp_cmdshell 'c:\path\file.exe' "Kannan" <gk_i@yahoo.com> wrote in message...
    2. stored procedure help
      Hi all! I am in need of writing a few stored procedures. The first one is to create a stored procedure to recover a database from backup and the...
    3. Using a stored procedure
      I am trying to pass a ProdID to a stored procedure, but I get an error: Error Executing Database Query. Procedure &apos;PriceBreak&apos; expects...
    4. stored procedure value
      How can I bind a stored procedure value to a page? I've executed a stored procedure and there should be two column values created...i.e. col1 and...
    5. need help on a stored procedure
      I have 2 tables. table1 and table2 I do a select on table1 and join table 2 on id. I want to check newprice in table1. if it is null, I want to...
  3. #2

    Default Re: Frustrating Stored Procedure Prob

    Try putting:
    set nocount on
    at the beginning of the stored procedure.

    "Andrew Paton" <andrew.paton@nospamplease.nufsaid.net> a écrit dans le message de news: [email]eYthI2MQDHA.3768@tk2msftngp13.phx.gbl[/email]...
    > I have the Simple Stored Procedure:
    >
    > CREATE PROCEDURE dbo.spCreateCart
    > AS
    > BEGIN
    > INSERT tblCart
    > VALUES (getdate())
    > SELECT @@IDENTITY as cartID
    > END
    > GO
    >
    > When i run this in stored procedure it works fine, i get my record created
    > and it returns the field i want under the alias 'cartID'
    >
    > However when i try to grab this value using the following ASP i get an 'Item
    > cannot be found in the collection corresponding to the requested name or
    > ordinal.' Error.
    >
    > SQL = "EXEC dbo.spCreateCart"
    > rsCreateCart = conn.execute(SQL)
    >
    > cartID = rsCreateCart("cartID")
    > response.write cartID
    >
    > I know that my connection is fine - since it works with other sections of
    > the script. And i have checked field names etc. This one really has me
    > stumped. Does anyone have any ideas?
    >
    > Thankyou
    >
    >
    >
    Guest

  4. #3

    Default Re: Frustrating Stored Procedure Prob

    "Andrew Paton" wrote ...
    > However when i try to grab this value using the following ASP i get an
    'Item
    > cannot be found in the collection corresponding to the requested name or
    > ordinal.' Error.
    Try collecting the value in your ASP like this...

    strCartID = RS(0)

    See if that works :)

    Robb


    Robb Meade Guest

  5. #4

    Default Re: Frustrating Stored Procedure Prob

    "Andrew Paton" wrote ...
    > However when i try to grab this value using the following ASP i get an
    'Item
    > cannot be found in the collection corresponding to the requested name or
    > ordinal.' Error.
    Try collecting the value in your ASP like this...

    strCartID = RS(0)

    See if that works :)

    Robb


    Robb Meade Guest

  6. #5

    Default Re: Frustrating Stored Procedure Prob

    From BOL:
    Each INSERT, UPDATE, and DELETE statement returns a result set containing only the number of rows affected by the modification...
    When the NOCOUNT option is set on, SQL Server does not return the counts of the rows affected by a statement.

    It is good practice to always include 'set nocount on' in all INSERT, UPDATE, and DELETE procedures, unless you really want to return Rowcount to the client. This also boosts performance.

    If you do not include it, you have to use:
    "set rsCreateCart = rsCreateCart.nextrecordset"
    in your ASP page to access "cartID".

    "Andrew Paton" <andrew.paton@nospamplease.nufsaid.net> a écrit dans le message de news: e2p5U$MQDHA.3016@TK2MSFTNGP10.phx.gbl...
    > >Try putting:
    > >set nocount on
    >
    > Thankyou this worked a treat - can i ask what difference setting no count on
    > makes?
    >
    >
    >
    Guest

  7. #6

    Default Re: Frustrating Stored Procedure Prob

    From BOL:
    Each INSERT, UPDATE, and DELETE statement returns a result set containing only the number of rows affected by the modification...
    When the NOCOUNT option is set on, SQL Server does not return the counts of the rows affected by a statement.

    It is good practice to always include 'set nocount on' in all INSERT, UPDATE, and DELETE procedures, unless you really want to return Rowcount to the client. This also boosts performance.

    If you do not include it, you have to use:
    "set rsCreateCart = rsCreateCart.nextrecordset"
    in your ASP page to access "cartID".

    "Andrew Paton" <andrew.paton@nospamplease.nufsaid.net> a écrit dans le message de news: e2p5U$MQDHA.3016@TK2MSFTNGP10.phx.gbl...
    > >Try putting:
    > >set nocount on
    >
    > Thankyou this worked a treat - can i ask what difference setting no count on
    > makes?
    >
    >
    >
    Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139