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

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

问题描述

尝试在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.然后检查选项卡驱动程序中已安装的驱动程序. 名称列指示您应该在连接字符串或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位Windows上的64位驱动程序 你的系统.要查看安装了哪些32位驱动程序,请按⊞Win + R ,然后键入:C:\Windows\SysWOW64\odbcad32.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:\Windows\SysWOW64\odbcad32.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位).如果不存在,则您可能正在运行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天全站免登陆