How to use VBScript to access a 32bit ODBC System DSN (Excel) on a Windows 7 64bit system?


  • What is the correct way to connect to a 32bit System DSN (Excel) on a Windows 7 64bit system?


    I've recently switched from Windows XP Pro x32 to Windows 7 x64.  Now, one of my scripts that uses an ODBC connection will no longer work.  After a bit of searching, I discovered that Windows 7 x64 does not currently have 64bit Excel drivers.  However, you can set up 32-bit connections by running "C:\Windows\SysWOW64\odbcad32.exe".  Unfortunately, my script still won't work even though I set up the System DSN exactly like I did on my old computer.  When I run my script, I get the following error:


    Script:  X\XML_Check.vbs
    Line:  212
    Char:  3
    Error:  [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application.
    Code:  80004005
    Source:  Microsoft OLE DB Provider for ODBC Drivers

    Line 212 contains:
    objConnection.Open "DSN=charge_codes_XLS;"

    It seemed to me that wscript.exe will only communicate properly with an identical environment (x32 to x32 or x64 to x64, but not x64 to x32 or x32 to x64).  With that in mind, I found a way around the error by running my script via the 32bit version of Windows Script Host.  I changed the shortcut path from "X:\XML_CHECK.vbs" to "C:\Windows\SysWOW64\wscript.exe X:\XML_CHECK.vbs" and the script appears to function ok. 

    What I really want to know is if there is a way to run my script via the 64bit version of wscript.exe yet have it connect to the 32bit ODBC subsystem? Is there a specific connection string I can use or am I just out of luck until Microsoft puts out 64bit Excel drivers?

    Thursday, April 08, 2010 4:04 PM


  • I've had similar problems with scripts that access SQL Server databases. I've used an ODBC connection string for years that has worked on every OS, but fails on any 64-bit OS. I searched on the connectionstrings web site linked below and switched to a connection string that uses an OLE DB provider for SQL Server.

    Fortunately, the OLE DB provider has also worked on the 32-bit OS's I have tested. Perhaps you can find a driver for Excel at the above web site that will work on 64-bit OS's. It covers just about everything.

    Richard Mueller

    Tuesday, April 27, 2010 5:04 PM

All replies