14

I have googled for hours now.

I have read countless articles such as: Is there a Windows 7 ODBC driver for Access?

I have tried using both the ODBC admin - and have managed to successfully add there system DSN for both:

  • Microsoft Access Database
  • Microsoft do Access Database

When I attempt to connect to Access DB stored locally:

odbc_connect('Aquarius2', '', '');

I get the following error(s):

odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application, SQL state IM014 in SQLConnect in C:\export\export.php on line 3

Simple script tried installing the latest access drivers - Aquarius2 is the name of my DSN still fails.

I'm out of ideas - what am I missing?

Regards, Alex

Community
  • 1
  • 1
Alex.Barylski
  • 2,843
  • 4
  • 45
  • 68

2 Answers2

20

You are attempting to use a 64 bit application with a 32 bit ODBC driver or vice versa. Look at ODBC on 64-bit Windows Platforms.

You need to determine whether your PHP application is 64 bit or 32 bit first.

Then once you've ascertained that you need to start the correct ODBC administrator - there are 2 of them, one for 32 bit and one for 64 bit. The 64 bit ODBC administrator is in Adminstrative tools, control panel and the 32 bit one is in %windir\syswow64\odbcad32.exe.

Once you've matched your application architecture to the right ODBC administrator, you need to create the system DSN. If you cannot find the MS Access driver in the administrator, you'll need to download one for that architecture. I'm not sure if there is a 64 bit MS Access ODBC driver; if there isn't, you'll have to change your application architecture.

The article I referenced has more information.

TallTed
  • 9,069
  • 2
  • 22
  • 37
bohica
  • 5,932
  • 3
  • 23
  • 28
  • I think I have already done all that and its clear that it is some kind of 32/64 bit mismatch but I am not sure why. – Alex.Barylski Feb 10 '12 at 14:01
  • I don't know how to rephrase my answer to make it any clearer - sorry. – bohica Feb 10 '12 at 16:54
  • The application is using PHP and it's odbc_x() API - running phpinfo() appears to tell me the ODBC API is win32. – Alex.Barylski Feb 10 '12 at 19:36
  • It seems only the 32bit version of ODBC will allow me to even setup access drivers - so unless I install something you are correct no 64 bit version of access drivers exist. Can I not use the 32 bit drivers under windows 7/64? What dictates whether I should use 32 or 64? The PHP odbc api? Or the OS? – Alex.Barylski Feb 10 '12 at 19:42
  • 2
    Turns out the PHP version I was running was for WIN64 - didn't even occur that might be the issue but installing a WIN32 version seems to have fixed the mismatch. Much thanks :) – Alex.Barylski Feb 10 '12 at 20:22
  • 1
    Confusingly, if you type `odbcad32.exe` at the command prompt, it appears to work, but actually you are not getting the "32 bit odbc administrator" that bohica referenced. Make sure to run `%windir%\syswow64\odbcad32.exe` – Fabio Beltramini Nov 12 '13 at 20:42
  • I cannot see what you mean by ["32 bit odbc administrator" that bohica referenced]. I clearly pointed out the default administrator on 64 bit windows is the 64 bit one accessible from the control panel and provided the path to the 32 bit one. You comment seems to add confusion rather than clarify anything. – bohica Nov 13 '13 at 10:27
  • Your answer said "The 64 bit ODBC administrator is in Adminstrative tools, control panel and the 32 bit one is in %windir\syswow64\odbcad32.exe". In the phrase "the 32 bit one", "one" refers to an "ODBC administrator" from the first part of the sentence. I was explicitly clarying for anyone that may be used to accessing their "32 bit odbc administrator" by typing "odbcad32.exe" at the command prompt (as was possible in the past) that this did not produce the same effect as what you had specified. – Fabio Beltramini Nov 13 '13 at 13:59
  • I tried the answer by @FabioBeltramini and it worked. And experienced that typing odbcad32.exe and %windir%\syswow64\odbcad32.exe will run same window but when you click system DSN tab then DSN created on these window doesn't appear on each-other while user DSN will appear in both of them. – Dipen Jan 16 '15 at 10:18
4

One other note: if you installed the 64-bit WampServer, it installs 64-bit everything - Apache, MySQL, PHP. If you want a 32-bit PHP to have around, go to the PHP downloads page and choose one of the 'win32' releases. And don't forget to change your php path when you run your application! This plus setting up the 32-bit ODBC administrator - %windir\syswow64\odbcad32.exe - and you should be good to go.

Alessandro Minoccheri
  • 35,521
  • 22
  • 122
  • 171
sagesmondo
  • 41
  • 1
  • Strange thing is, even though I installed a 64bit version of wampServer, PHP_INT_MAX constant was equal to 2^31-1, so I thought PHP was 32 bit somehow. Downloading 32bit wampserver now and keeping my finger crossed. – Mchl Sep 30 '13 at 09:25
  • Yes. It worked! Although switching wampserver versions is a bit of a PITA. – Mchl Sep 30 '13 at 10:17