DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: ASP and ADO Command

  1. #1
    sosoc Guest

    ASP and ADO Command


    How can I read the returned value from a SQL Server store procedure using
    an ASP ADO Command Object. I tried to add to the command's parammeters collection
    a new one as a return_value parameter or an output parameter and didn't work...
    Any ideas or sample source code?

    Thanx

  2. #2
    Randy Guest

    Re: ASP and ADO Command


    The first parameter you add should be the return value. After you execute
    the procedure check the value of this parameter to see the return value of
    the stored procedure. They have examples in the ADO help files.



  3. #3
    Carl Guest

    Re: ASP and ADO Command


    Here's a simple snippet of code that calls a stored procedure which attempts
    to save a user's email address in the database, and returns a string (@validated)
    indicating the success or failure of the operation.

    In the CreateParameters for @validated, the 200 is the data type, 3 indicates
    it is an output parameter, and 125 is the length of the data type (in this
    case it is a varchar(125))

    Assign values to all the parameters in the stored procedure (even the output
    one), execute the stored procedure, then look at the output parameter value
    to see what the output is.

    dbCmd.CommandText="user_aliasSave";
    dbCmd.Parameters.Append( dbCmd.CreateParameter("@login_id", 200, 1, 30));
    dbCmd.Parameters.Append( dbCmd.CreateParameter("@email_address", 200, 1,
    125));
    dbCmd.Parameters.Append( dbCmd.CreateParameter("@validated", 200, 3, 125));
    dbCmd.Parameters("@login_id").value=Request("login_id");
    dbCmd.Parameters("@email_address").value=Request("email_address");
    dbCmd.Parameters("@validated").value="";
    dbCmd.Execute();
    validStr=dbCmd.Parameters("@validated").value;
    ...

    -carl


    "sosoc" <sorin_ctin@k.ro> wrote:
    >
    >How can I read the returned value from a SQL Server store procedure using
    >an ASP ADO Command Object. I tried to add to the command's parammeters collection
    >a new one as a return_value parameter or an output parameter and didn't

    work...
    >Any ideas or sample source code?
    >
    >Thanx



  4. #4
    Mike Larkin Guest

    Re: ASP and ADO Command


    "sosoc" <sorin_ctin@k.ro> wrote:
    >
    >How can I read the returned value from a SQL Server store procedure using
    >an ASP ADO Command Object. I tried to add to the command's parammeters collection
    >a new one as a return_value parameter or an output parameter and didn't

    work...
    >Any ideas or sample source code?
    >
    >Thanx



    You can simply check Parameter(0) which is always the return value.

    For example if you have a return statement in your stored proc then the following
    VB code will be able to retrieve it.

    Dim lResult as long
    lResult = ADOCommand.Parameters(0)



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center