ODBC Call Failed – Error 3151 on Windows 7 64-bit and how to fix it

ODBC Call Failed - Error 3151 su Windows 7 a 64-bit: Come risolvere

If you stumbled upon this issue, chances are you’re (re)installing an old software client on a new-or-newly-updated Windows 7 64-bit system. That program – often an archive/administrative/management service client or a similar home-made piece of software –  uses a persistent ODBC connection to a local or remote DB via an ODBC DSN interface defined at user or system level using the Windows ODBC Administrator tool.

The Problem

The aforemetioned client can’t find the ODBC Data Source entry, therefore showing an error pop-up containing the following:

ODBC Call Failed – Error 3151

Or, depending on the ODBC driver installed:

ODBC Connection Failed – Error 3146

First thing we need to do is to check if the latest version of the Windows ODBC is properly installed and if a proper Data Source pointing to the DB we need to connect has been set: you can check both of these by opening the Windows Control Panel and navigate through Administrative Tools -> ODBC Data Source Administrator. If there’s something missing there, fix that and check again, otherwise keep reading.

The Analisys

This specific issue is mostly related to how Windows 7 and above handles ODBC connections. Starting from Win7 the OS contains two different ODBC Data Source Administration tool executables: the 32-bit one and the 64-bit one. You can find them in the following folders, as explained in a note of this official KB article:

ODBC Administrator (32-bit)

ODBC Administrator (64-bit)

Which one should we use? It obviously depends on the Data Source we need to set-up. If your client supports a 64-bit connection driver you will go with the x64 version, otherwise you need to use the 32-bit one. If you’re experiencing the Error 3151 problem and your ODBC connection works, chances are you’re doing the right thing while using the wrong tool, i/e the 64-bit ODBC Administrator instead of the 32-bit one.

The Fix

Needless to say, the problem can be fixed by launching the proper ODBC Administrator tool, which – if you’re here – often is the 32-bit one.

The fact that the latest versions of Windows are shipping two different executables having an identical filename to handle ODBC connections isn’t ideal and can obviously lure the users and administrators in doing configuration errors. Microsoft addressed that in Windows 8 and later, where the Control Panel’s Administrative Tools features two different icons to handle the two different ODBC Administrator builds:

windows-8-control-panel-odbc-32bit-64bit

Unfortunately, as of today Windows 7 x64 Administrative Tools panel is still featuring a single icon, pointing to the 64-bit edition of the ODBC Administrator. The choice, as mentioned in this KB article, could be related to some retro-compatibility issues. Anyway, that’s the main reason why a lot of users and administrators keep stumbling upon this issue and struggle fixing that by carefully reading the KB or by Googling it up until they reach posts like this one.

In case you need more insights on this specific scenario, here’s a couple useful links regarding some mostly related issues:

That’s about it: happy connection!

 

RELATED POSTS

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies.

View all posts by Ryan