gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 07:43:29 25 4
gpt4 key购买 nike

我有一些从 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com