Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2002
    Posts
    2

    Unanswered: OLEDB driver omits SP return value

    Hi,

    I have a problem with some ATL7/OLEDB code. I'm trying to execute stored procedures from my application. I do get a result set back, but I never get a correct return value back. I've been going through MSDN articles as well as other articles on the web, and I just cannot see what I'm doing wrong!

    I have this piece of ATL code:
    <pre>
    // code generated on den 6 juni 2002, 10:56

    [
    db_command(L"{ ? = CALL dbo.MyProc(?) }")
    ]
    class CMyProc
    {
    public:
    [ db_column(1, status=m_dwIdStatus, length=m_dwIdLength) ] LONG m_Id;
    /* and so on - 7 columns total */

    [ db_param(1, DBPARAMIO_OUTPUT) ] LONG m_RETURN_VALUE;
    [ db_param(2, DBPARAMIO_INPUT) ] LONG m_id;

    void GetRowsetProperties(CDBPropSet* pPropSet)
    {
    pPropSet->AddProperty(DBPROP_CANFETCHBACKWARDS, true, DBPROPOPTIONS_OPTIONAL);
    pPropSet->AddProperty(DBPROP_CANSCROLLBACKWARDS, true, DBPROPOPTIONS_OPTIONAL);
    }
    };

    </pre>

    When I use this code I do:
    <pre>
    CSession dbsession;
    CDataSource dbsource;
    CDBPropSet dbinit(DBPROPSET_DBINIT);
    /* fill dbinit with connection parameters */
    /* HRESULTs not checked for brevity*/
    dbsource.Open(_T("SQLOLEDB.1"), &dbinit);
    dbsession.Open(dbsource);

    CMyProc proc;
    proc.m_id = 1;
    proc.Open(dbsession);

    TRACE("Return value is %d\n", proc.m_RETURN_VALUE);

    /* Take care of result set - which exists and is valid! */
    </pre>

    The return value is <tt>-858993460</tt> which is <tt>0xcccccccc</tt>. In Visual C++ this value is used as an "uninitialized" stack value during debug. It seems as if ATL never bothers to update my return value parameters! I even made a little experiment with an extra output parameter - same thing there.

    I'm using Visual C++ .NET and the SQL 2000 OLEDB provider (SP2). I've also tried this without attributed programming in both Visual C++ .NET and Visual C++ 6.

    Does anybody have a clue what is going on??

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    Is the stored procedure using set nocount on ? If not, put it in the stored procedure.

    Good luck.

  3. #3
    Join Date
    Jun 2002
    Posts
    2
    Thanks for replying!

    I tried with and without nocount and had no success.

    I tried something else the other day though; I generated a non-attributed CCommand-class using CMultipleResults as template parameter. Then I could get all out parameters by calling GetNextResult() on the command object.

    So my question is now; how do I make the attribute-injector generate a CCommand class for me using CMultipleResults?

Posting Permissions

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