str.Format("%d",n);
strCmd = "updatedata_tele @id = " + str + ",@value = 1.456";
m_pCommand->CommandText = (_bstr_t)strCmd;
m_pCommand->Execute(NULL, NULL, adCmdStoredProc);在执行Execute时出错,怎么回事啊?谢谢!

解决方案 »

  1.   

    而且你这个也不是存储过程呀,存储过程就像一个表名一样,不是SQL语句。你这个是代参数的SQL语句!
      

  2.   

    看一个例子
    _ConnectionPtr adoConn(__unidof(Connection));
    _CommandPtr adoCmd(__uuidof(Command));adoConn->Open(_bstr_t(m_strConnection),"","",-1);
    adoCmd->ActiveConnection = adoConn;adoCmd->CommandText = _bstr_t(m_strCmdText);
    adoCmd->CommandType = adCmdStoredProc;_ParameterPtr parm;
    //存储过程的输入参数
    parm = adoCmd->CreateParameter("input",adInteger,adParamInput,4,m_iInput);
    adoCmd->Parameters->Append(parm);
    parm = adoCmd->CreateParameter("output",adInteger,adParamOutput,4,m_iOutput);
    adoCmd->Parameters->Append(parm);adoCnd->Execute(NULL,NULL,-1);long i = 8;
    m_iOutput = adoCmd->Parameters->Item[i]->Value;
      

  3.   

    这个是存储过程,存储过程的名字就是updatedata_tele,有两个参数:id和value这些语句在连接sybase数据库时是可以正确执行的,只是我把连接字符串改成ms sql server后就出错了,不知道为什么?
      

  4.   

    搞定了,呵呵
    我把语句
    m_pCommand->Execute(NULL, NULL, adCmdStoredProc);
    中的最后一个参数改成-1就可以运行了,不知道为什么会这样?多谢各位了,哈哈