FIX: "Unhandled exception" in MFC DAO App After VC++ 5.0 SP1Last reviewed: December 1, 1997Article ID: Q172405 |
The information in this article applies to:
SYMPTOMSAfter installing the MFC42.dll (version 4.21.7160) that ships with Visual C++ 5.0 Service Pack 1, applications that were compiled with Visual C++ 4.2 and use MFC DAO may fail with an unhandled exception or MFC may display a "Command Failed" error message. Specifically, the exception will occur when creating index fields (CDaoTableDef::CreateIndex) or retrieving information about index fields (CDaoTableDef::GetIndexInfo). If you catch the exception to examine the error message you will see "No error message is available".
CAUSEApps compiled with Visual C++ 4.2 should use DAO 3.0. DAO 3.0 GUIDs were redefined (in DBDAOID.H) after DAO 3.5 was released and MFC DAO source was not modified to use the new definitions. There are two places where MFC DAO uses the wrong GUIDs.In DaoCore.cpp:
RESOLUTIONPossible workarounds for this problem are:
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been fixed in Visual Studio 97 Service Pack 3. For more information, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q170365 TITLE : INFO: Visual Studio 97 Service Packs - What, Where, and Why MORE INFORMATIONFollowing is an excerpt from DBDAOID.H included with Visual C++ 5.0:
// The pre-3.5 GUIDs have been redefined with "30" added to the ID. // For example: // IID_IDAOIndex becomes IID30_IDAOIndex //This way both the 30 and 3.5 GUIDs can be used at once.
Steps to Reproduce BehaviorThe following code will reproduce the error:
CString strFilename = _T("c:\\db1.mdb"); // Create a dao database CDaoDatabase database; database.Create(strFilename); // Create "DEFAULT" table CDaoTableDef tableDef(&database); tableDef.Create(_T("DEFAULT")); // Create a single field "IDENTIFIER" CDaoFieldInfo fieldInfo; fieldInfo.m_strName = _T("IDENTIFIER"); fieldInfo.m_nType = dbText; fieldInfo.m_lSize = 255; fieldInfo.m_lAttributes = 0; fieldInfo.m_nOrdinalPosition = 0; fieldInfo.m_bRequired = FALSE; fieldInfo.m_bAllowZeroLength = FALSE; fieldInfo.m_lCollatingOrder = 0; tableDef.CreateField(fieldInfo); // Create the primary key CDaoIndexFieldInfo indexFieldInfo; indexFieldInfo.m_strName = _T("IDENTIFIER"); indexFieldInfo.m_bDescending = FALSE; CDaoIndexInfo indexInfo; indexInfo.m_strName = _T("IDENTIFIER"); indexInfo.m_pFieldInfos = &indexFieldInfo; indexInfo.m_nFields = 1; indexInfo.m_bPrimary = TRUE; indexInfo.m_bUnique = TRUE; indexInfo.m_bClustered = FALSE; indexInfo.m_bIgnoreNulls = FALSE; indexInfo.m_bRequired = TRUE; indexInfo.m_bForeign = TRUE; indexInfo.m_lDistinctCount = 0; tableDef.CreateIndex(indexInfo); // Generates exception Keywords : MfcDAO VS97FixlistSP3 Component : dao Version : WINDOWS NT:5.0sp1 Platform : NT WINDOWS Issue type : kbbug Solution Type : kbfix kbservicepack |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |