A recordset with no records returns a value of 0. When working with attached tables or ODBC databases, GetRecordCount always returns – 1. Calling the Requery member function on a recordset resets the value of GetRecordCount just as if the query were re-executed.来自MSDN
The number of records in the recordset; 0 if the recordset contains no records; or –1 if the record count cannot be determined
如果是,就把游标设为adUseClient
pRecordset->CursorLocation = adUseClient;
int count = 0;
pRecordset->MoveFirst();
while(!pRecordset->EOF)
{
count++;
pRecordset->MoveNext();
}
pRecordset->MoveLast();