CString m_strRemorcaNmb; // value for this string is set before
CString path = "DB\\dataBase";
CDaoDatabase db;
try
{
db.Open(path, 0, 0, "");
CDaoRecordset rs(&db);
rs.Open(AFX_DAO_USE_DEFAULT_TYPE, _T("SELECT Numar_inmatriculare FROM Masini;"), 0);
COleVariant searched(m_strRemorcaNmb);
BOOL bFound = rs.Seek("=",&searched);
}
在这里,我尝试验证我的数据库 (.mdb) 中是否包含 CString 值。当它到达BOOL bFound = rs.Seek("=",&searched);
一个debug assertion failed
错误被抛出。在对话框中点击重试,应用程序会daocore.cpp
在此行触发断点ASSERT(m_nOpenType == dbOpenTable);
。