locked
DAO Database functionality in C++ called from a 64 bit app. RRS feed

  • Pergunta

  • Hello,
      I write 3rd party  software in C++ that runs on top of an engineering program called AutoCAD.    We have various applications that do this but one of them Creates ,  Accesses and manipulates a database using the DAO functions offered by MFC's  CDaoDatabase with some CDaoRecordset's in it.    This .dll (which AutoCAD calls an .arx) has to be generated as an x64 app on the 64 BIT version of AutoCAD (i.e. the one that installs automatically on XP 64 and Vista 64) .  

    The generated database is used by another 32-bit portion of our software.   This works well because the JET engine and the new ACE engine (for Access 2007)  are both 32 bit from what I can tell and run in WOW64 on a 64bit machine.    So our 32 bit software has no trouble getting at these databases.    
    But my piece of the puzzle, that has traditionally generated the database, cannot use the DAO functions any more when I try to build the project as an x64 app.     It give me :
    fatal error C1189: #error :  DAO Database classes are not supported for Win64 platforms
    This error makes sense to me , knowing that the JET and ACE database formats are both only in 32bit.    
    Also, the _AFX_NO_DAO_SUPPORT preproccesor variable gets set in there somewhere as well when building an x64 build, so a host of other DAO dependencies don't get defined as a result.

    So to get around this problem on the 64 bit version of this project, I've decided to create a 64bit wrapper for the DAO functions so I can call them from my 64 bit app and still generate that .mdb file I've been generating that's 32 bit compliant and can be picked up by our other 32-bit in Wow64.    

    I am just setting out to write my own wrappers (as is suggested here: http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/91855c63-b2a3-46fb-aec4-f2b087988555/) but then I thought , I'm sure other people have had this problem and to see if anyone has already created a wrapper to get at DAO functions from a 64 bit app, that's out there somewhere.   I looked around on MSDN and online in general and didn't find anything.   
    Any help would be much appreciated,
    Roy

    A couple references that convinced me to try this tactic instead of converting to ADO or OLE DB:
    Developing Access 2007 Solutions with Native C or C++
    http://msdn.microsoft.com/en-us/library/cc811599.aspx

    Accessing 32-bit DLLs from 64-bit code
    http://dnjonline.com/article.aspx?ID=jun07_access3264

    quarta-feira, 6 de maio de 2009 21:20

Respostas

  • No, dao and jet are dodo.  MSFT has been trying to get rid of it since 2001, x64 gave them the opportunity.  Yes, there are ways to invoke 32-bit code from x64.  But it is fugly, you'll need out-of-process COM or some other kind of interprocess communication mechanism.  Sooner or later you'll have to face the fact, sooner is always better than the ohmigod-we-need-it-now moment.

    I'm sure you know what needs to be done.

    Hans Passant.
    • Marcado como Resposta nobugz sexta-feira, 31 de julho de 2009 19:36
    quarta-feira, 6 de maio de 2009 21:53

Todas as Respostas

  • No, dao and jet are dodo.  MSFT has been trying to get rid of it since 2001, x64 gave them the opportunity.  Yes, there are ways to invoke 32-bit code from x64.  But it is fugly, you'll need out-of-process COM or some other kind of interprocess communication mechanism.  Sooner or later you'll have to face the fact, sooner is always better than the ohmigod-we-need-it-now moment.

    I'm sure you know what needs to be done.

    Hans Passant.
    • Marcado como Resposta nobugz sexta-feira, 31 de julho de 2009 19:36
    quarta-feira, 6 de maio de 2009 21:53
  • I agree with Hans. It's time to stop reaching for the duct tape.
    quarta-feira, 6 de maio de 2009 22:02
  • We are working through the same boat as you (AutoCAD application that uses DAO) and ended up deciding a 64bit wrapper for DAO was the best way to go. Our wrapper is basically complete for the functionality that we need. If you want to swap notes, I'd be happy to share with you over email (I'm not sure this forum is the best place for that). My email is david at designmaster dot biz.
    domingo, 26 de julho de 2009 02:49
  • Hello sir, I saw your question in 2020. . . Yes, eleven years latter.

    I would love to know how your project finally solved this problem.
    Very similar, my company is a software publisher, the software uses Access 1995 as a local embedded database (no network connection required), and cdaodatabase cdaorecordset in c # to access data.
    Dao has long been deprecated. Many people recommend converting to ADO or OLE DB, but after 2007 Access uses accdb file type, and to access files, client must install access database engine 2010 on the client side.
    This is very troublesome. Unlike the jet engine, msjet40.dll comes with the system, however for accdb engine we cannot simply add a reference in our programme. And moreover, all functions written in cdao must be rewritten. I don’t know why converting to ado or ado.net is quickly.

    Even today in 2020, I searched on github and there is no wrapper you mentioned, which makes me feel very strange. I would love to know how these projects ended up solving this problem.
    Some people suggest converting access to sqlite or other third-party databases. For now, SQL server compact edition is not feasible because it will be deprecated in 2021. Sqlite seems to be a good choice. But rewriting the functions using cdao still exists, seems unavoidable. This workload is huge. So I want to hear your opinion.
    If you can share your experience, I will be very grateful.

    quarta-feira, 22 de abril de 2020 20:31