Results 1 to 3 of 3

Thread: Return Values?

  1. #1
    Join Date
    Feb 2004
    Posts
    134

    Unanswered: Return Values?

    Using ado, the _CommandPtr::Execute method returns a recordset. When calling a storedproc with this method, does the 'return' statement return the value in a recordset ?

    EG:
    Code:
    //c++ ADO
    _CommandPtr pCmd(__uuidof(Command));
    ............
    _RecordsetPtr pRs = pCmd->Execute(NULL, NULL, adCmdStoredProc);
    
    // Stored proc
    CREATE PROCEDURE usp_my_proc
    AS
    SELECT .... FROM tbMyTable WHERE x = something
    IF(@@ERROR <> 0)
               return -1
    .....
    What in the case of an error would be returned to pRs recordset?
    Any thoughts?

    Mike B

  2. #2
    Join Date
    Apr 2004
    Posts
    64
    In the event of an error, the execute method will not return a recordset. It will return and error.
    If you want to obtain a return value rather than a recordset you should include an output parameter in your SP, SET its value and retrieve it after executing the SP.

  3. #3
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    That's not exactly correct. If @@error <> 0 then the return value will be what you specified in RETURN, in this case -1.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

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