tags:

views:

95

answers:

1

Here is the code:

CDatabase m_db;
m_db.OpenEx(_T( "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=mydb;UID=root;PASSWORD=123123;OPTION=3;"), FALSE );
CRecordset recSet(&m_db);
recSet.Open(AFX_DB_USE_DEFAULT_TYPE, _T("SELECT * From articles"), CRecordset::executeDirect);
int nRecords = recSet.GetRecordCount(); // Equals to 1!

the article table has more than 1000 records. I tried with different database/tables but problem not fixed!

+2  A: 

That's a limitation of the way CRecordset works. You'll need to call MoveNext until IsEOF returns TRUE, then the record count will be accurate.

Mark Ransom
What Mark said. See http://msdn.microsoft.com/en-us/library/aa312382(VS.60).aspx for info about CRecordset members.
Steven Richards