Solved

Using MFC DAO Classes using Apache Handler

Posted on 2013-05-10
6
698 Views
Last Modified: 2013-05-22
I am trying to access an Access Database using an Apache handler.

I have written a C++ Console App based on MFC that uses DAO classes to access an Access database on a Windows 7 64 system.  It works as expected when I launch in it a cmd window

I have Apache running on this computer,  with the same login credentials when running the console.

When I attempt to run the program in Apache I get the error:  Unable to initialize DAO/Jet db Engine.  If I comment out the line to open the database, the program works and it's console output is displayed in the browser window.

I have checked that I am running Apache and the Program under the same user.  I have checked that I am setting the correct DAO version (3.6).   I have checked and installed DAO360, registered it.

Somehow, when Apache attempts to launch the program, something is preventing the DB drivers from loading, but when I launch the same program in a console window, no problem.
0
Comment
Question by:BeachCoder
  • 3
  • 2
6 Comments
 
LVL 35

Expert Comment

by:mccarl
ID: 39158165
Is the Access DB specified as a filename or a DSN? If a filename, are you using absolute paths or are you making sure the current directory is set correctly?
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 39158522
DAO 3.6 and the Jet database engine are only compatible with 32 bit applications.  it is my suspision that when running from the command prompt, you are at 32bit, but in Apache, you are at 64bit.

you may want to consider installing the ACE 12 (A2007) database engine to handle 32 bit, then install ACE 14 (Access 2010)/64bit database engine for your 64 bit needs.  then you can use Microsoft Office Access database engine objects (which is DAO vNext).

please note I am talking about the database engine installation only not the full blown versions of access.
0
 

Author Comment

by:BeachCoder
ID: 39159496
mccarl - The error occurs attempting to construct the MFC DAO interface, the program never gets to the point where a specific database is opened.

datAdrenaline: I am running the standard Apache binaries (which are 32-bit, I don't think they are available from Apache in 64-bit yet).  I will try installing the different ACE database engines and see if that makes a difference.  

As an aside, when doing research I came across a post when the ODBC drivers are being incorrectly pulled from system32, and not sysWOW64.  There probably is some mixing of 32/64/:  (Ignore the microsoft responses as not-helpful).

http://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/odbc-drivers-missing-in-windows-7-home-premium-64/56139d24-f903-43ff-8f3e-363e467795a6
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Accepted Solution

by:
BeachCoder earned 0 total points
ID: 39174815
I tried a clean install using Windows 7 32-bit to see if it was a 32/64 conflict, but the same behavior:  Works fine in a console window, but when attempting to launch through Apache get error Unable to initialize DAO/Jet DB Engine.  Apache is running under the same user as the logged in user.

The best solution was to rewrite the routines moving away from DAO (CDaoWorkspace) and towards ODBC (CDatabase).  Seems to work fine under the ODBC drivers.  To use the ODBC drivers, need to use the ODBC Drivers Missing on 64 bit windows link above to configure them correctly.
0
 

Author Closing Comment

by:BeachCoder
ID: 39186862
Workaround, not solution to problem.
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 39187137
thanks for posting your workaround! good luck on your project!
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question