为什么我收到“未找到数据源名称且未指定默认驱动程序"?我该如何解决? [英] Why am I getting "Data source name not found and no default driver specified" and how do I fix it?

查看:30
本文介绍了为什么我收到“未找到数据源名称且未指定默认驱动程序"?我该如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 Windows 上制作通过 ODBC 连接到数据库的程序时,出现以下错误:

When trying to make a program on Windows that connects to a database via ODBC, I got the following error:

[Microsoft][ODBC 驱动程序管理器] 未找到数据源名称且未指定默认驱动程序.

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

我确定我的代码是正确的.它甚至可以在不同的 PC 上运行.

I'm sure my code is right. It even worked on a different PC.

为什么我会收到这个错误?我该如何解决?

Why am I getting this error? And How do I fix it?

推荐答案

导致此错误的原因是什么?

简单地说,错误消息告诉您 ODBC 驱动程序管理器找不到您在连接字符串或 DSN 中指定的驱动程序.

What causes this error?

The error message tells you, simply put, that the ODBC Driver Manager could not find the driver you specified in your connection string or DSN.

这可能有 3 个常见原因:

This can have 3 common causes:

  1. 您尝试使用的驱动程序未安装在您的系统上
  2. 驱动程序已安装,但与您正在运行的代码的位数不匹配
  3. 您在输入驱动程序名称时出错

如何检查我的系统上安装了哪些驱动程序?

您可以通过访问 ODBC 数据源管理器来检查系统上安装的驱动程序.要打开它,请按 ⊞ Win + R,然后输入:odbcad32.exe.然后检查标签 Drivers 以获取已安装的驱动程序.Name 列指示您应该在连接字符串或 DSN 中使用的确切名称.

How do I check which drivers are installed on my system?

You can check the drivers which are installed on your system by going to the ODBC Data Source Administrator. To open it, press ⊞ Win + R, and type in: odbcad32.exe. Then check the tab Drivers for installed drivers. The Name column indicates the exact name you should use in your connection string or DSN.

如果您使用的是 64 位 Windows,则仅列出安装在其上的 64 位驱动程序你的系统.要查看安装了哪些 32 位驱动程序,请按 ⊞ Win + R,然后输入:C:WindowsSysWOW64odbcad32.exe,然后再次转到 Drivers 标签.

If you're on 64-bit Windows, that only lists the 64-bit drivers installed on your system. To see which 32-bit drivers are installed, press press ⊞ Win + R, and type in: C:WindowsSysWOW64odbcad32.exe, and go to the Drivers tab again.

然后,您有两种选择,要么调整程序运行的位数,要么安装不同位数的驱动程序.

Then, you have two choices, either adjust the bitness your program is running in, or install a driver with a different bitness.

某些默认安装在 Windows 上的驱动程序只有 32 位变体.这些不能用于 64 位程序.

Some of the drivers that are installed by default on Windows only have a 32-bits variant. These can't be used with 64-bits programs.

您通常可以在任务管理器中识别程序在哪个位下运行.在 Windows 10 中,所有 32 位程序的名称后都附加了 (32-bit).如果不存在,则您可能正在运行 64 位程序,并且大多数现代编程语言和环境默认在 64 位上运行,但允许您切换到 32 位.但是,不同编程语言的细节超出了本问题的范围.

You can usually identify which bitness a program is running under in task manager. In Windows 10, all 32-bit programs have (32-bit) appended to their name. If that isn't there, you're likely running a 64-bit program, and most modern programming languages and environments run on 64-bit by default, but allow you to switch to 32-bit. However, the specifics for different programming languages are outside the scope of this question.

一个 ODBC 连接字符串如下所示:

An ODBC connection string looks like this:

DRIVER={DriverName};ParameterName1=ParameterValue1;ParameterNameN=ParameterValueN;

如果驱动程序名称部分可能包含特殊字符,则需要用大括号分隔,并且需要与 ODBC 数据源管理器中已安装的驱动程序名称完全匹配,包括空格和印刷字符,但不包括大写.

The driver name part needs to be delimited by curly braces if it might contain special characters, and needs to exactly match the installed driver name, as found in the ODBC Data Source Administrator, including spaces and typographical characters, but excluding capitalization.

请注意,对于已部署的代码,驱动程序必须存在于运行代码的计算机/服务器上.

Note that for deployed code, the driver must be present on the computer/server running the code.

这取决于您要使用的驱动程序.

That depends on which driver you want to use.

具有下载位置的常用驱动程序列表(所有 32 位和 64 位在同一 URL):

A list of common drivers with download locations (all 32-bit and 64-bit at the same URL):

  • The Microsoft ODBC Driver 17 for SQL Server
  • The Microsoft Access database driver, which is part of the Microsoft Access Database Engine. Note that simultaneous installations of 32-bit and 64-bit Access ODBC drivers are not supported.
  • The MySQL ODBC connector by Oracle
  • The open-source SQLite ODBC driver by Christian Werner (non-official)
  • psqlODBC, the official PostgreSQL driver

如果未列出您要使用的驱动程序,通常可以使用 Google 轻松找到该位置.

If the driver you want to use isn't listed, the location is usually easily found using Google.

这篇关于为什么我收到“未找到数据源名称且未指定默认驱动程序"?我该如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆