Stored Procedure Output using ASP

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

  1. #1

    Default Stored Procedure Output using ASP


    Hi,

    I've written an sproc which inserts customer data into a SQL table, then
    stores a variable as the unique id of the row (@orderid) ... then
    inserts data into abother table using this parameter @orderid

    The problem I have is although I can execute this sproc from my asp code
    ... I need to output the value of @orderid to my asp page and I don't
    know how to do this.

    I run the sproc by using this code:

    set dborders = server.createobject("ADODB.Connection")
    dborders.open "Driver={SQL
    Server};Server=orac;Database=database;Uid=user;Pwd =password;"

    strsql = "exec transfersproc" & chr(39)& session.sessionid & chr(39)
    & chr(44) & _
    chr(39) & strcustomername & chr(39)& chr(44) & _
    chr(39) & strcompanyname & chr(39)& chr(44) & _
    chr(39) & strcustomerEmail & chr(39)& chr(44) & _
    chr(39) & strcustomeraddress & chr(39)& chr(44) & _
    chr(39) & strcustomeraddress2 & chr(39)& chr(44) & _
    chr(39) & strcustomeraddress3 & chr(39)& chr(44) & _
    chr(39) & strcustomercity & chr(39)& chr(44) & _
    chr(39) & strcustomerPostCode & chr(39)& chr(44) & _
    chr(39) & strcustomerphone & chr(39)& chr(44) & _
    chr(39) & strcustomermobile & chr(39)& chr(44) & _
    chr(39) & strordertotal & chr(39)& chr(44) & _
    chr(39) & strbusinessuse & chr(39)& chr(44) & _
    chr(39) & stremployees & chr(39)& chr(44) & _
    chr(39) & straboutus & chr(39)& chr(44) & _
    chr(39) & strtextdispatch & chr(39)& chr(44) & _
    chr(39) & strtextoffers & chr(39)& chr(44)


    can someone please tell me what I need to add to my sproc to get an
    output parameter and also how I access it in my code ... please??

    M3ckon

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    m3ckon Guest

  2. Similar Questions and Discussions

    1. 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...
    2. Stored procedure?
      Stored procedure ?? -- Message posted via http://www.dotnetmonster.com
    3. Retrieve output parameters from failed stored procedure
      Is it possible to retrieve output parameters (adParamOutput) from a stored procedure (asp/sql server) even when the procedurte fails - or is it...
    4. 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...
    5. Stored Procedure with Image Output
      Hi! I'm trying to get image in a parameter (this parameter is declared as 'output') from stored procedure, but it causes an exception: "A severe...
  3. #2

    Default Re: Stored Procedure Output using ASP

    m3ckon wrote:
    > Hi,
    >
    > can someone please tell me what I need to add to my sproc to get an
    > output parameter and also how I access it in my code ... please??
    >
    Read the following text from my FAQ folder and get back to us to tell us the
    method you wish to use to return the value.

    To help your decision, methods 2 and 3 require the use of a Command object,
    which can be troublesome to write code for. Fortunately, free code
    generators have been written, including mine which is available at

    [url]http://www.thrasherwebdesign.com/index.asp?pi=links&hp=links.asp&c=&a=clear[/url]

    ************************************************** **
    There are 3 ways to return values from a SQL Server stored procedure:
    1. a Select statement that returns a resultset
    --run this script in Query Analyzer (QA):
    Create Procedure SelectValue
    (@input int)
    AS
    Select @input + 5
    go
    exec SelectValue 10
    go
    drop procedure SelectValue


    2. a Return parameter:
    --run this script in QA:
    create procedure ReturnValue
    (@input int)
    AS
    Return @input + 5
    go
    declare @returnvalue int
    exec @returnvalue = ReturnValue 10
    select @returnvalue
    go
    drop procedure ReturnValue

    3. an Output Parameter:
    --run this script in QA:
    create procedure OutputValue
    (@input int output)
    AS
    SET @input = @input + 5
    go
    declare @outputvalue int
    SET @outputvalue = 10
    exec OutputValue @outputvalue output
    select @outputvalue
    go
    drop procedure OutputValue


    I do not recommend method 1 for returning a single value. A resultset is
    expensive to build, in that it must contain metadata in addition to data. So
    more network traffic is created, and the client app needs to expend more
    resources in order to retrieve and expose the resultset to the calling
    procedure.

    Most developers use the Return parameter to return status codes instead of
    data. This is for the sake of consistency: there is no technical reason not
    to use RETURN to return data, except that RETURN can only be used to return
    integers. If you need to return other datatypes, you need to use an output
    parameter.
    ************************************************** *****



    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] 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