封装Ado的时候,怎样用Ado来判断,输入的语句是select xxx还是,insert or update。
因为如果使用插入,删除等语句。GetRecordCount会出错。
在msdn查询说要用bof 和 eof 都为true时,表示没有记录。可是用智能指针
pRecordSet->get_adoEOF(&comvEOF),VC报告没有改函数,查找msdn ado 2.7告诉我有
pRecordSet->get_EOF函数,靠,VC居然没找到!则么解决呀?请高手赐教!

解决方案 »

  1.   

    利用RecordsAffected参数
                    _bstr_t bstrEmpty;
                   Conn1.CreateInstance( __uuidof( ADODB::Connection ) );
                   Conn1->ConnectionString = bstrConnect;
                   Conn1->Open( bstrConnect, bstrEmpty, bstrEmpty, -1 );
                   _variant_t records_affected;
                   Conn1->Execute((LPCTSTR)sqlcmds,&records_affected,0);//VT_I4,lVal
    注意:RecordsAffected does not return the number of records returned by a result-returning query or stored procedure. 
      

  2.   

    可以通过GetStatus,如果是完成Update insert 命令的时候recordsetptr->getstatus = adoClose.可以通过这来判断,就不要获得记录集了.因为recordset已经关闭了,如果使用GetrowCount,会得到错误提示