CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 1999
    Posts
    3

    How to use output param in a stored procedure thru. vc++

    Hi,

    I am working in vc++(MFC) connected to sybase adaptive server anywhere(ODBC).
    I am having trouble getting results from a stored Procedures.

    The object is to execute a stored procedure and get the result.
    I tried using output parameters,but it's not yielding.
    (I am able to pass parameters to a stored procedure)

    Help me to solve this problem.

    rds,
    Md.Noorul


  2. #2
    Join Date
    Jul 1999
    Location
    Lodz, Poland
    Posts
    26

    Re: How to use output param in a stored procedure thru. vc++

    Hi!

    I had similar problem in OLE DB. I had to use following syntax:

    "? = call ProcedureName (?, ?,...)"

    to get return value and output parameters back.

    Regards
    Cih



  3. #3
    Join Date
    Oct 1999
    Posts
    3

    Re: How to use output param in a stored procedure thru. vc++

    Hello,

    Thank you for your reply.

    But I had tried this syntax.
    It is working only for input parameters.

    For output parameters I am using like this...
    ///////////////////////////////////////////////////////////////////////////////////////////////
    ////////////In DoFieldExchange
    pFX->SetFieldType(CFieldExchange:utputParam);
    RFX_Text(pFX, _T("[count]"), m_outParam);

    ///////In Open function
    Open(0,"{Call GetCount(?)}");

    /////////////////////Stored procedure in backend
    alter procedure mmd.GetCount(out @cnt varchar(10))
    /* RESULT ( column-name,... ) */
    begin
    select COUNT(*) into @cnt from mmd.PatientInfo;
    select* from mmd.Social_Info,mmd.PatientInfo where Social_Info.PatientId='3'
    end
    ///////////////////////////////////////////////////////////////////////////////////////////////
    But this is not working.
    pl.check this and inform me if you find any error.
    Or get me a way to solve this problem in other way.

    Regards,
    Md.Noorul




  4. #4
    Join Date
    Oct 1999
    Location
    Shenzhen, P.R.China
    Posts
    35

    Re: How to use output param in a stored procedure thru. vc++

    Here I is some code, wish it will help you.

    global variables:
    _ConnectionPtr pConn;
    _CommandPtr pCommand;

    code for connection:
    HRESULT rslt;
    CoInitialize(NULL);
    rslt=pConn.CreateInstance("ADODB.Connection");
    rslt=pConn->Open("DSN=?","<User name>","passward",adOpenUnspecified);
    hr=pCommand.CreateInstance("ADODB.Command");


    code in get parameter:

    _ParameterPtr pParaIn;
    _ParameterPtr pParaOut;
    ParametersPtr pParas;
    BSTR bstrValue;
    <assign the input parameter to bstrValue>
    pParaIn=pCommand->CreateParameter("<Index string>",adBSTR,adParamInput,sizeof(bstrValue),bstrValue);
    pParas=pCommand->Parameters;
    pParas->Append(pParaIn);
    pParas->Append(pParaOut);
    pCommand->ActivConnection=pConn;
    pCommand->CommandType=adCmdStoredProc;
    pCommand->CommandText="Procedure Name";
    pCommand->Execute(?,?,adCmdStoredProc);
    Now, the out put parameter may in pParaOut.


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured