_variant_t RecordsAffected;
   HRESULT hr;
try
{
hr=m_pConnection->Execute(_bstr_t(sqlstring), &RecordsAffected, adCmdText);
}catch(...){...}
   此时:RecordsAffected为确发器的SQL语句影响的行数,我怎么才能把本身SQL语句所影响的行数取出来?

解决方案 »

  1.   

    A pointer to memory in which to return the count of rows affected by a command that updates, deletes, or inserts rows. If cParamSets is greater than one, *pcRowsAffected is the total number of rows affected by all of the sets of parameters specified in the execution. If the number of affected rows is not available, *pcRowsAffected is set to DB_COUNTUNAVAILABLE on output. If riid is IID_IMultipleResults, the value returned in *pcRowsAffected is either DB_COUNTUNAVAILABLE or the total number of rows affected by the entire command; to retrieve individual row counts, the consumer calls IMultipleResults::GetResult. If the command does not update, delete, or insert rows, *pcRowsAffected is undefined on output. If pcRowsAffected is a null pointer, no count of rows is returned.
      

  2.   

    就是说pcRowsAffected是执行updates, deletes, or inserts rows
    你取不出行数是不是sqlstring有问题
      

  3.   

    no count of rows is returned.
      

  4.   

    我能取出,但如果有确发器时,取出的是第一个确发器中第一个SQL语句返回的值。也就说取不到正确的值。
      

  5.   

    怎么办?我只想到如果是UPDATE,delete时,返回0可能是没有影响记录,但其他时候只要成功了,就不管了。