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

    Question

  • 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:

    Quote:

    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

Answers

  • 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.

    http://www.connectionstrings.com/

    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


    MVP ADSI
    Tuesday, April 27, 2010 5:04 PM

All replies

  • bump

     

    Same problem here. Anyone?

    Tuesday, April 27, 2010 10:14 AM
  • What is the correct way to connect to a 32bit System DSN (Excel) on a Windows 7 64bit system?

    AFAIK (and I'm not an ODBC expert and I don't use Excel), you can't unless there are 64-bit drivers.

    Bill

    Tuesday, April 27, 2010 4:41 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.

    http://www.connectionstrings.com/

    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


    MVP ADSI
    Tuesday, April 27, 2010 5:04 PM
  • Hi

    Try this

    http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=c06b8369-60dd-4b64-a44b-84b371ede16d

    Works ok for me as long as my application runs but the application crashes on close, for some PCs

     

    /Mikael


    sTf_paPs
    Monday, March 07, 2011 2:00 PM
  • I faced the same issue recently. There was a 32bit MSOffice installed on the 64bit server and the same visual basic code worked from MS Office script debugger, and did not in the cscript/wscript.
    It seems that 
      - the  cscript/wscript used 64bit ODBC driver
      - the  office used     32bit ODBC driver
    Excel drivers are installed for 32bit ODBC (because of 32 bit office the ODBC manager 32bit was a full hand of drivers).
    Excel drivers are NOT installed for 64bit ODBC manager (because of 32 bit OFFICE) and can not be installed while the 32bit MS OFFICE is installed.
    The SQL drivers are installed for 64bit ODBC (so that is why the SQL connection was established well)


    The solution would be to run .js .vbs scripts in 32 bit environment:

    \windows\SysWOW64\cscript.exe or \windows\SysWOW64\wscript.exe 

    Search for more with: how do i run a vbscript in 32 bit mode on a 64 bit machine

    Friday, June 06, 2014 3:18 PM