4,018
社区成员




int ADO::getcount(CString tablename)
{
_RecordsetPtr pRst(__uuidof(Recordset));
CString strSQL;
strSQL.Format("select * from %s",tablename); //如果是select count(*) from %s pRst得到的又是什么?
pRst->Open(_variant_t(strSQL),_variant_t((IDispatch*)m_pConnection),adOpenDynamic,adLockOptimistic,adCmdText);
return (pRst->RecordCount);
}
strItem.Format(_T("%s"),COleDateTime::GetCurrentTime().Format(_T("Created: %I:%M:%S %p, %m/%d/%Y")));
int ADO::getcount(CString tablename)
{
_RecordsetPtr pRst(__uuidof(Recordset));
CString strSQL;
strSQL.Format("select * from %s",tablename);
pRst->CursorLocation = adUseClient;
// pRst->Open(_variant_t(strSQL),_variant_t((IDispatch*)m_pConnection),adOpenDynamic,adLockOptimistic,adCmdText);
pRst->Open((LPCTSTR)strSQL,_variant_t((IDispatch*)m_pConnection),adOpenStatic,adLockOptimistic,adCmdText);
/* int i=1;
while(!pRst->adoEOF)
{
i++;
pRst->MoveNext();
}
return i;
*/
return (pRst->RecordCount);
}
_RecordsetPtr pRst(__uuidof(Recordset));
CString strSQL;
strSQL.Format("select * from %s",tablename);
pRst->Open(_variant_t(strSQL),_variant_t((IDispatch*)m_pConnection),adOpenDynamic,adLockOptimistic,adCmdText);
int i=1;
while(!pRst->adoEOF)
{
i++;
pRst->MoveNext();
}
return i;