Error -2147467259 When Using SQL Toolkit or Database Connectivity Toolkit on Windows 7 64-bit

Updated Dec 22, 2023

Reported In

Software

  • LabVIEW
  • LabVIEW Database Connectivity Toolkit
  • LabWindows/CVI
  • LabWindows/CVI SQL Toolkit

Operating System

  • Windows

Issue Details

I am using 32-bit LabVIEW or LabWindows/CVI on Windows 7 64-bit, and I am getting the following error from the DB Tools Open Connection VI:

Error -2147467259 (0x80004005)
ADO Error: Exception occurred in Microsoft OLE DB Provider for ODBC driver. 
Microsoft ODBC Driver manager: The specified DSN contains an architecture mismatch between the driver and application in NI-Database-API.lvlib


Why am I receiving this error, and how do I resolve it?

Solution

This error is thrown because the 64-bit version of odbcad32.exe, the ODBC Data Source Administrator program, was used to configure the Data Source Name (DSN) to the database when the 32-bit version of the ODBC Data Source Administrator program should have been used.

First, be sure of having the 32-bit version of MySQL installed. There will be two different files named odbcad32.exe on Windows 7 x64.  Even though both are named odbcad32.exe, one is 64-bit and the other is 32-bit.  You can tell which is 64-bit and which is 32-bit by their directory location:
  • 64-bit version is in <Windows>/SysWOW64
  • 32-bit version is in <Windows>/System32

There are two options to correct the error: 
  1. Fix the ODBC setup. To do this, open the 64-bit version of odbcad32.exe, delete the database configuration, then open the 32-bit version as an Administrator and configure the database there.
  2. Change your LabVIEW or LabWindows/CVI code to use the UDL with the exact connection string. You can learn more about this in How Do I Set Up a Microsoft Data Link File (UDL) Through LabVIEW?

Additional Information

The 32-bit LabVIEW or LabWindows/CVI application is trying to use the DSN created by the 64-bit odbcad32.exe to connect to the database, and this is not architecturally possible.  This is the architecture mismatch mentioned in the error message.  The 32-bit LabVIEW or LabWindows/CVI application can only use DSNs created with the 32-bit version of odbcad32.exe.  This issue is discussed on the Microsoft Developer Network's article Managing Data Sources.