c++ - Microsoft Access 数据库 - "record too large"异常

标签 c++ database mfc

我有一些从 MS Access 数据库中读取的代码。该代码如下:

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;

我的问题是,有时 会抛出异常。消息框显示,

Database error: Record too large

我的数据库有 > 30000 条记录。

为什么会出现这个异常?另外,为什么它有时会发生?

谢谢!

最佳答案

你可以自己搜索答案,但无论如何引用 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.

您可以尝试使用备忘录类型作为 answer建议。

关于c++ - Microsoft Access 数据库 - "record too large"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15340383/

相关文章:

c++ - 以平台无关的方式将值序列化为字节串

c++ - 为什么在循环条件(即 `while (!stream.eof())`)内的iostream::eof被认为是错误的?

c++ - MFC对话框列表控件的工具提示

c++ - 下一个 C++ 标准中即将出现的 R 值引用是什么?

c++ - 如何使用 openssl 或任何其他带有智能卡签名的库创建 PKCS7 signedData 结构?

java - JBoss 中的数据源绑定(bind)

c# - MongoDB 中的正则表达式 + 选项(C# 驱动程序)

mysql - MYSQL求两点之间的距离。 (使用点数据类型)

c++ - COleControl的ActiveX和HWND

c++ - 如何只替换 CString 中第一次出现的字符?