Fix Data Source Name Not Found ODBC Error

“Data source name not found and no default driver specified” means the ODBC driver manager cannot find the requested data source or determine which database driver to use. The fix is usually to correct the connection string, make the data source available to the application’s account, or install a driver that matches the application’s architecture. Use these symptoms to narrow the problem before changing database or network settings.

Symptom Likely Cause First Check
The error started after changing a connection string Incorrect DSN or driver name Compare the configured name with the registered name
The database driver is missing from the driver list Driver not installed or registered Check drivers visible to the application
A DSN exists, but the application cannot use it Application and driver architecture differ Check the application’s bitness
It works interactively but fails as a service or scheduled task Different account or runtime configuration Inspect the connection under the failing account
It works locally but fails in a container ODBC components or configuration exist only on the host Inspect the running container
A workbook works on another computer Local driver or DSN configuration is missing Compare the two computers’ ODBC setup

What the ODBC Error Means

ODBC connections involve several separate components:

Application → ODBC driver manager → database driver → database

The application might be Excel, a Python script, an R session, or a background service. The driver manager selects the database-specific driver and passes it the connection settings.

This error commonly appears with SQLSTATE IM002:

[IM002] [Microsoft][ODBC Driver Manager]
Data source name not found and no default driver specified

There are two common ways to identify the connection:

  • DSN-based connection: The application supplies a data source name, such as ReportingDSN. The driver manager looks up that saved configuration.
  • DSN-less connection: The application supplies a driver name and connection details directly.

A DSN is a local configuration name, not necessarily the database name, server name, or hostname. Creating a database called ReportingDSN does not create an ODBC data source with that name.

The configuration that matters is the one visible to the failing process, not the one visible in your own desktop session.

That distinction explains why a connection can work in an administrator’s test but fail in Excel, a service, or a container.

How to Fix the ODBC Data Source Error

The repair identifies the effective connection, matches the driver architecture, repairs the DSN, and corrects the application connection string.

Step 1: Identify the Actual Connection and Runtime

  1. Capture the complete error, including its SQLSTATE. A similar-looking driver-loading or authentication error may require a different repair.
  2. Identify the program that opens the connection, the computer or container where it runs, and the account running it.
  3. Inspect the connection string the program actually uses. Check environment variables, configuration files, workbook connections, and deployment settings, not just the value in your source code.
  4. Remove passwords, tokens, and other secrets before sharing diagnostic output.

For a DSN-based connection, identify the value after DSN=:

DSN=ReportingDSN;

For a DSN-less connection, identify the value after DRIVER=:

DRIVER={Exact Registered Driver Name};

These are connection-string fragments, not complete database connection examples. If the string supplies only a server and database, without a usable DSN or driver, the driver manager may have no way to select a driver.

Record the intended DSN or driver name before changing anything.

Step 2: Check the Driver and Application Architecture

On Windows, match the driver to the application’s architecture, not merely to the operating system.

  1. For a 64-bit application, search Start for ODBC Data Sources (64 bit) and choose Run as administrator when creating or repairing a system-wide source. For a 32-bit application, open ODBC Data Sources (32 bit) instead, elevating it when necessary.
  2. Open the Drivers tab.
  3. Find the driver required by your database and copy its registered name exactly.
  4. If it is missing, install the database vendor’s ODBC driver for the application’s architecture, then reopen the administrator and confirm that it appears.

On x64 Windows, the executable locations are counterintuitive. To open the native administrator, enter this in the Windows Run dialog:

%windir%\System32\odbcad32.exe

To open the administrator for x86 applications, use:

%windir%\SysWOW64\odbcad32.exe

Installing a Python or R package does not install every database vendor’s native ODBC driver. Likewise, having a JDBC driver installed does not satisfy an ODBC connection.

A User DSN appearing in an administrator window is not, by itself, proof that its associated driver has the correct architecture.

Step 3: Create or Repair the DSN

If your application uses a DSN-less connection, you do not need to create a DSN.

For a DSN-based connection:

  1. In the matching ODBC administrator, look for the exact requested name under User DSN and System DSN.
  2. Select an existing entry and choose Configure to inspect it. If the entry is missing, choose the appropriate tab and select Add.
  3. Select the intended installed driver.
  4. Enter the DSN name and the driver-specific server, database, and authentication settings.
  5. Save the configuration and use the driver’s connection-test button if one is available.

Choose System DSN when accounts beyond the Windows user creating the connection must use it. A User DSN is visible only to its creating user, while a System DSN is available to other users on that computer, per IBM’s ODBC data-source command reference. System-wide visibility does not grant database permissions.

When naming the data source, keep the DSN name to a maximum of 32 characters. Make the application’s DSN= value match the configured name exactly, including spaces.

Prefer correcting an existing entry over deleting it blindly: other applications may depend on that DSN.

Step 4: Correct the Application’s Connection String

Save a copy of the existing configuration, then update the connection method the application actually uses.

For a DSN-based connection, use the saved data-source name:

DSN=ReportingDSN;

Provide authentication through the application’s supported mechanism. Do not assume that a DSN stores a reusable password.

For a DSN-less connection, use the exact registered driver name and the connection keywords supported by that driver.

For SQL Server, common registered names include ODBC Driver 17 for SQL Server and ODBC Driver 18 for SQL Server. Confirm the exact installed name in the Drivers tab or the application’s driver-list output; do not substitute a version number merely because it is newer.

For example, this connection string uses Microsoft’s named driver with Windows authentication:

DRIVER={ODBC Driver 17 for SQL Server};SERVER=your-server;DATABASE=your-database;Trusted_Connection=yes;

Replace the server and database placeholders. Windows authentication uses the identity running the application, so this example is appropriate only when that identity has database access.

If an older configuration contains DRIVER=SQL Server, change it only to the name of the intended installed replacement. Switching driver versions can also change connection behavior, including encryption defaults.

Step 5: Test From the Failing Application

  1. Save the revised configuration.
  2. Close and reopen the client, or restart the affected worker so it reloads its connection settings.
  3. Retry the connection under the original account and in the original runtime.
  4. Open a known table or run a harmless query appropriate for the database.

A successful ODBC administrator test is useful, but the application must also succeed.

If IM002 disappears and you receive a login, certificate, or network error instead, driver selection has progressed. Diagnose that new error rather than repeatedly rebuilding the DSN. Do not disable certificate validation or open firewall ports merely to address a driver-selection error.

Excel and Background-Service Connections

Excel and background processes connect successfully when the required driver and connection configuration exist for their actual runtime.

Excel Workbooks

Excel connections depend on the local Office installation and connection type.

  1. Check whether the installed Excel application is 32-bit or 64-bit. The driver must match Excel.
  2. Open Data > Queries & Connections and locate the failing connection.
  3. For a workbook connection, open Properties > Definition and inspect its connection string. For a Power Query query, inspect the connection settings it actually uses.
  4. Correct the referenced DSN or driver, and make sure it exists on the computer running Excel.
  5. Save the workbook and select Data > Refresh All.

A workbook can carry a connection reference without carrying the installed database driver or the computer’s DSN configuration. Copying the workbook alone therefore may not reproduce a working setup.

Services, Scheduled Tasks, and Web Applications

For a background process, identify the actual execution account and host before changing configuration.

  1. Inspect the service, task, or application-pool settings to identify its account.
  2. Check which configuration file and environment variables that process loads.
  3. Provision the required driver and connection configuration on the execution host, not merely on the database server or your workstation.
  4. Restart the affected process and trigger a real task or request.
  5. Check its logs for a successful connection and database operation.

If both a User DSN and a System DSN have the same name, inspect both. A user-specific entry can cause an interactive session to resolve a different configuration from the service.

Avoid treating “run the application as administrator” as a permanent repair. Elevation does not correct a misspelled driver name, an incompatible driver architecture, or missing database permissions.

Python and R Connections

Python With pyodbc

If the application uses pyodbc, run this diagnostic code in the same interpreter that produces the error:

import struct
import sys
import pyodbc
print("Python executable:", sys.executable)
print("Process architecture:", struct.calcsize("P") * 8)
print("ODBC drivers:", pyodbc.drivers())
print("ODBC data sources:", pyodbc.dataSources())

The executable path helps distinguish a notebook kernel, virtual environment, IDE interpreter, or service installation. The architecture output is in bits.

Compare the returned driver and data-source names with the effective connection string. An empty driver list indicates that this runtime is not seeing registered drivers; reinstalling pyodbc alone is unlikely to correct that.

After repairing the connection configuration, test it and close the connection:

import pyodbc
connection = pyodbc.connect("DSN=ReportingDSN;")
try:
    print("Connected to:", connection.getinfo(pyodbc.SQL_DBMS_NAME))
finally:
    connection.close()

Replace the example DSN with yours and supply authentication through your application’s existing secure mechanism if required. Then rerun the original program, not just the diagnostic script.

R With the odbc Package

Before connecting with R package odbc, install an ODBC3 driver manager and database drivers; both are required components in the package’s official documentation. Installing the R package is not a substitute for installing the database driver.

List what the current R process can see:

odbc::odbcListDrivers()
odbc::odbcListDataSources()

Use the driver or DSN name returned by those functions rather than guessing it. For a DSN-based connection, test the corrected name:

con <- DBI::dbConnect(
  odbc::odbc(),
  dsn = "ReportingDSN"
)
DBI::dbIsValid(con)
DBI::dbDisconnect(con)

Add the authentication arguments your database requires. A valid connection confirms that the lookup and connection succeeded; disconnecting releases the test connection.

If the failure occurs in a scheduled R job or hosted R process, repeat the test there. A successful desktop R session does not validate a different runtime’s configuration.

Linux, macOS, and Container Connections

Linux, macOS, and container repairs verify the driver manager, registered drivers, DSN configuration, and runtime environment.

Inspect unixODBC Configuration

Windows includes an ODBC driver manager. On Linux and macOS, R’s odbc package uses unixODBC; other applications must also use configuration compatible with their driver manager.

Run this command in the failing environment to find unixODBC’s configuration locations:

odbcinst -j

List registered drivers:

odbcinst -q -d

List configured data sources:

odbcinst -q -s

If the utility is unavailable, establish whether unixODBC is installed and accessible to that runtime. Install the driver manager and the database vendor’s driver using packages supported for the runtime’s operating system and architecture.

Then repair the relevant configuration:

  1. Open the configuration files identified by the location command.
  2. In odbcinst.ini, confirm that the driver registration points to the installed driver library.
  3. In odbc.ini, confirm that the DSN section name matches the application’s requested DSN.
  4. Confirm that the DSN’s Driver setting resolves to the intended registered driver or supported library path.
  5. Save the files and rerun the listing commands under the application’s account.

For example, a section headed [ReportingDSN] defines a data source named ReportingDSN; the configuration filename itself is not the DSN.

Check which configuration files and environment variables the failing runtime loads if they appear to differ from those in your terminal. Also confirm that its account can read the configuration and load the driver library.

Restart the client process and retry the actual database operation. If the error changes to “can’t open lib,” investigate the library path, architecture, and dependencies rather than continuing to rename the DSN.

Apply the Fix Inside Containers

A host computer’s working ODBC configuration is not automatically available inside a container.

  1. Inspect drivers and configuration inside the running application container.
  2. Install the native driver manager and database driver in the runtime image, not only in a build stage.
  3. Include or mount the required nonsecret ODBC configuration, with paths valid inside the container.
  4. Supply credentials through your deployment’s secret mechanism.
  5. Rebuild and redeploy the image, then test under the container’s normal runtime user.

For Kubernetes, inspect the application container in the failing Pod. Another container or an administrator’s local shell can have different drivers, files, and environment variables.

Finish by executing the original application operation and checking its logs. Make the repair reproducible in the image or deployment configuration; an interactive edit inside a running container will disappear when that container is replaced.

How to Confirm the Fix and Prevent Recurrence

A complete repair should satisfy this checklist:

  • The original application connects using its normal account.
  • A real database read or other intended operation succeeds.
  • The connection still works after restarting the client or redeploying the workload.
  • Background jobs succeed independently of an interactive desktop session.
  • Credentials remain out of source code and diagnostic logs.

Record the application architecture, exact driver name, DSN scope, and configuration locations alongside the deployment instructions. Provision these dependencies deliberately when moving a workbook, application, or service to another machine.

Your next action should be to rerun the operation that originally failed, not merely confirm that a DSN appears in a configuration window.

Frequently Asked Questions

Do I Need to Set a Default ODBC Driver?

No. Most applications should explicitly identify a configured DSN or a registered driver in their connection settings. The phrase “no default driver specified” does not mean you need to choose a universal default driver in Windows.

Does This Error Mean My Database or Data Is Damaged?

No. SQLSTATE IM002 identifies a connection-selection problem, not evidence of database corruption. Do not restore a backup or recreate a database solely because this message appears.

Should I Reinstall Excel to Fix a Data Source Error?

Usually not. Reinstalling Excel will not necessarily recreate a missing DSN or install the database vendor’s ODBC driver. Consider repairing Office only when you have separately established that the ODBC configuration is correct and the failure is specific to the Office installation.

Why am I getting the “data source name not found and no default driver specified” ODBC error?

The “data source name not found and no default driver specified” ODBC error occurs when the application cannot locate the requested DSN or determine which database driver to use. Verify that every character of the DSN matches the configured name, and use a driver with the same 32-bit or 64-bit architecture as the application. If more than one Windows account must use the connection, configure the data source as a System DSN rather than only for one user.