Microsoft KB Archive/230485

= How To Create an Access 2000 Database with MFC DAO =

Article ID: 230485

Article Last Modified on 8/30/2005

-

APPLIES TO


 * Microsoft Visual C++ .NET 2003 Standard Edition
 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q230485



Note Microsoft Visual C++ .NET (2002) supports both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code.



SUMMARY
This article describes how to create an Access 2000 (Jet 4.0) database in Visual C++ 6.0. To create an Access 2000 database, it is necessary to use DAO 3.6 by setting the version of MFC to 6.01 at run time. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

236991 PRB: Unrecognized Database Format Error with Access 2000 Database

Specify the DAO version explicitly as 0x40 in the CDaoDatabase::Create method as described in the MORE INFORMATION section below.

NOTE: Creating an Access 2000 database requires Jet 4.0 and DAO 3.6 installed on the computer. Jet 4.0 is installed with MDAC 2.1 and Office 2000. DAO 3.6 is installed with Office 2000.



Steps to Create Access 2000 Database
 Create an MFC dialog box-based application.  Add a command button to the dialog box resource. Add the following code to the command button handler: AfxGetModuleState->m_dwVersion = 0x0601; CDaoDatabase db; db.Create("NewDatabase.mdb",dbLangGeneral,0x40);

  Add the following code to Stdafx.h:                     Compile and run your application.
 * 1) ifndef _AFX_NO_DAO_SUPPORT
 * 2) include           // MFC DAO database classes.
 * 3) endif // _AFX_NO_DAO_SUPPORT

