How can I use DAO 3.6 in a MFC application

How can I use DAO 3.6 in a MFC application

Post by Matthias Hübne » Sat, 05 May 2001 21:22:37



Hallo,
I want to use the DAO36.DLL in my MFC application, because of using
CDaoWorkspace::CompactDatabase(...) for an Jet 4 data base (Access
2000). I do find the initializing code in MFC\inc\daocore.h :

// Determine whether to use DAO 3.6, 3.5, or 3.0
// Use DAO 3.0 if DLL build and not built with MFC 4.21 or later
// Use DAO 3.6 if MFC 6.01 or later
// otherwise, DAO 3.5

#ifndef _AFXDLL
#if _MFC_VER >= 0x0601
#define _AfxDetermineDaoVersion()   (36)
#else
#define _AfxDetermineDaoVersion()   (35)
#endif
#else // dynamically because of DLL
static inline BYTE _AfxDetermineDaoVersion()
{
 BYTE bReturn = 35;

#ifdef _AFXDLL
 AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
 if (pModuleState->m_dwVersion < 0x421)
  bReturn = 30;
 else if (pModuleState->m_dwVersion >= 0x0601)
  bReturn = 36;
#endif // _AFXDLL

 return bReturn;

Quote:}

#endif

What do this mean? My latest Version of MFC42.DLL is 6.00.8665.0 . Is
there anywhere a newer version? Or knows anybody a workaround?

Thanks for any help
Matthias Huebner

 
 
 

How can I use DAO 3.6 in a MFC application

Post by Crai » Sun, 06 May 2001 21:55:01


You need to add this line to your InitInstance of your MFC App:

AfxGetModuleState()->m_dwVersion >= 0x0601;

This will fool the compiler into using the 3.6 DLL's

Craig


> Hallo,
> I want to use the DAO36.DLL in my MFC application, because of using
> CDaoWorkspace::CompactDatabase(...) for an Jet 4 data base (Access
> 2000). I do find the initializing code in MFC\inc\daocore.h :

> // Determine whether to use DAO 3.6, 3.5, or 3.0
> // Use DAO 3.0 if DLL build and not built with MFC 4.21 or later
> // Use DAO 3.6 if MFC 6.01 or later
> // otherwise, DAO 3.5

> #ifndef _AFXDLL
> #if _MFC_VER >= 0x0601
> #define _AfxDetermineDaoVersion()   (36)
> #else
> #define _AfxDetermineDaoVersion()   (35)
> #endif
> #else // dynamically because of DLL
> static inline BYTE _AfxDetermineDaoVersion()
> {
>  BYTE bReturn = 35;

> #ifdef _AFXDLL
>  AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
>  if (pModuleState->m_dwVersion < 0x421)
>   bReturn = 30;
>  else if (pModuleState->m_dwVersion >= 0x0601)
>   bReturn = 36;
> #endif // _AFXDLL

>  return bReturn;
> }
> #endif

> What do this mean? My latest Version of MFC42.DLL is 6.00.8665.0 . Is
> there anywhere a newer version? Or knows anybody a workaround?

> Thanks for any help
> Matthias Huebner



 
 
 

1. Problem using DAO 3.6 with MFC

Hi,
I need to implement a small database program using DAO 3.6 and Access 2000
mdb file, in visual C++.
I have a problem using DAO 3.6 with MFC.
I'm using Win NT 4.0 with service pack 5 and MS-ACCESS 2000 installed also.
When i'm using VB 6.0 i can select in menu "project -> references" the
version of DAO i want to use.
Currently the items i have in the list on my machine are DAO 3.0, DAO 3.5
and DAO 3.6.
When i'm selecting the DAO 3.6 version in VB, everything is work ok, and i
can open without any problem MDB files created in Access 2000.
When i'm using DAO with MFC,meaning, i'm using classes like "CDaoDatabase"
and "CDaoRecordset", and i'm trying to open MDB files created with access
2000,i'm getting an exception about an unrecognized format.(for MDB files
created using Access 97 there is no problem).
Since with MFC  DAO classes opening access 2000 mdb files is failed,and
opening mdb files of access 97 is successfull,the only thing i can think
about is that when using MFC DAO classes the classes uses the incorrect or
an old version of DAO (possibly version 3.5 of DAO).
Why questions are:
- How can i control in visual C++ which version of the DAO is to be used ?
Is there a similar way to select the version of DAO to be used like in VB ?
- If visual C++ doesn't use the DAO 3.6, can i force him some how to use the
correct version ?

Any tip will be helpfull.

Thanks in advanced.

Gil


2. PRESS: SAP and Informix Announce First Joint U.S. Site

3. Using DAO 3.6 with Access 97 in a VB application

4. Changing fieldnames

5. Help - FPW 2.6 boots system when click on program item to access software

6. JET 4.0, DAO 3.6 with MFC

7. Contacting Informix?

8. Jet 4.0 and DAO 3.6 with mfc in SP3

9. Update Record delayed using DAO 3.6

10. Using VC 5 with DAO 3.6.

11. display chinese using DAO 3.6/VB6 in accessing Access 2000 DB.

12. PRB: Using DAO 3.6 with VB Data control