存储过程如下:
CREATE PROCEDURE pz_UpdateSimulator 
@intID int,
@vchPassword  varchar(255),
@fValue float,
update tabSimulator  set fdValue = @fValueOne, vPassword = @vchPassword
where fdID = @intID代码如下:
int ID = 5;
float fValue = 1.23;
CString strPWD("123"); 
try{
     _bstr_t bstrProc("pz_UpdateSimulator");
     m_pCommand->ActiveConnection = m_pConnection;
     m_pCommand->CommandText = bstrProc;
     m_pCommand->CommandType = adCmdStoredProc;
     m_pCommand->Parameters->Refresh();     -----如何添加输入参数?--------------------------------------     m_pCommand->Execute( NULL,NULL, adCmdUnknown );
}
catch ......看过一些代码,不过还是不明白...

解决方案 »

  1.   

    这样去调用带参数的存储过程:"{CALL pz_UpdateSimulator(ID,strPWD,fValue)}"
      

  2.   

    BOOL CADOCommand::AddParameter(CString strName, int nType, int nDirection, long lSize, _variant_t vtValue, int nPrecision, int nScale)
    {
    try
    {
    _ParameterPtr pParam = m_pCommand->CreateParameter  
                                             (strName.AllocSysString(), 
                                             (DataTypeEnum)nType, //数据类型
                                             (ParameterDirectionEnum)nDirection,//方向 
                                              lSize,//大小
                                              vtValue//值
                                              );//生成参数
    pParam->PutPrecision(nPrecision);
    pParam->PutNumericScale(nScale);
    m_pCommand->Parameters->Append(pParam);//添加到参数表中

    return TRUE;
    }
    catch(_com_error& e)
    {
    dump_com_error(e);
    return FALSE;
    }
    }
      

  3.   

    都可以,但我更愿意使用{? call test(?,?,?)}形式,
    因为它和执行sql语句基本一样,我的项目中也是这样作的
      

  4.   

    具体{? call test(?,?,?)}怎么写?多谢了!