Reputation: 2351
I have some code which reads from an MS Access database. That code is as follows:
CDatabase database;
CString sDriver = "MICROSOFT ACCESS DRIVER (*.mdb)";
CString sDsn;
CString sFile = "MyDB.mdb";
CString sField;
// Build ODBC connection string
sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s", sDriver, sFile);
TRY
{
// Open the database
database.Open(NULL, false, false, sDsn);
// Allocate the recordset
CRecordset recset(&database);
// Execute the query
recset.Open(CRecordset::forwardOnly, "SELECT NAME FROM INFOTABLE", CRecordset::readOnly);
// Loop through each record
while( !recset.IsEOF() )
{
// Copy each column into a variable
recset.GetFieldValue("NAME", sField);
// Add the obtained field to a drop-down box
m_dropDown.AddString(sField);
// goto next record
recset.MoveNext();
}
// Close the database
database.Close();
}
CATCH(CDBException, e)
{
// If a database exception occured, show error msg
AfxMessageBox("Database error: "+e->m_strError);
}
END_CATCH;
My problem is, an exception is thrown sometimes. The message box displays,
Database error: Record too large
My database has > 30000 records.
Why does this exception occur? Also, why does it occur sometimes?
Thanks!
Upvotes: 0
Views: 678
Reputation: 1854
You could search for an answer by yourself, but anyway quoting MSDN support -
Records in a table... in a Microsoft Access database are limited to slightly under 2K, not counting Memo fields. The "Record is too large" error occurs when you enter data into such a record, not when you define the table structure.
And you can try to use memo types as this answer suggests.
Upvotes: 1