如何使用 ODBC 连接到我的 64 位 SQL Server?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1954128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 04:51:11  来源:igfitidea点击:

How do I connect to my 64-bit SQL Server with ODBC?

sqlsql-server64-bitodbc

提问by soapergem

I recently installed SQL Server 2008 Express on my Windows 7 Ultimate x64 home machine. I also have IIS 7.5 with PHP 5.3, and I was trying to connect to SQL via ADODB, but kept getting this error:

我最近在我的 Windows 7 Ultimate x64 家用机器上安装了 SQL Server 2008 Express。我也有 IIS 7.5 和 PHP 5.3,我试图通过ADODB连接到 SQL ,但一直收到这个错误:

[Microsoft][ODBC Driver Manager] The specified DSN contains an
architecture mismatch between the Driver and Application

After doing a small amount of digging on the internet, I think this is because the SQL Server ODBC driver is meant for 32-bit operating systems, and mine's 64. First of all, am I correct? Is this the reason I'm running into trouble? Secondly, if so, how do I fix this? Are there any updated ODBC drivers that work with 64-bit operating systems? I looked but was unable to find any...

在互联网上进行了少量挖掘后,我认为这是因为 SQL Server ODBC 驱动程序适用于 32 位操作系统,而我的是 64 位操作系统。首先,我说得对吗?这就是我遇到麻烦的原因吗?其次,如果是这样,我该如何解决这个问题?是否有任何适用于 64 位操作系统的更新的 ODBC 驱动程序?我看了,但找不到任何...

回答by MkUltra

You're right in that it has to do with the bits.

你是对的,它与位有关。

Hope this helps:

希望这可以帮助:

--From MSDN --

——来自 MSDN ——

To manage a data source that connects to a 32-bit driver under 64-bit platform, use c:\windows\sysWOW64\odbcad32.exe. To manage a data source that connects to a 64-bit driver, use c:\windows\system32\odbcad32.exe. If you use the 64-bit odbcad32.exe to configure or remove a DSN that connects to a 32-bit driver you will receive this message.

管理64位平台下连接32位驱动的数据源,使用c:\windows\sysWOW64\odbcad32.exe。要管理连接到 64 位驱动程序的数据源,请使用 c:\windows\system32\odbcad32.exe。如果您使用 64 位 odbcad32.exe 配置或删除连接到 32 位驱动程序的 DSN,您将收到此消息。

回答by Scott

I've been having the same problem trying to link a 64 bit SQL 2012 server to 'Sage Timberline' using Pervasive ODBC Client Interface.

我在尝试使用 Pervasive ODBC Client Interface 将 64 位 SQL 2012 服务器链接到“Sage Timberline”时遇到了同样的问题。

I can set up the 32 bit DSN, but SQL Server keeps giving me the "architecture mismatch" error when trying to create a linked server using the 32 bit DSN.

我可以设置 32 位 DSN,但是在尝试使用 32 位 DSN 创建链接服务器时,SQL Server 一直给我“体系结构不匹配”错误。

回答by Sapen

I tried the C:\Windows\SysWOW64\odbcad32.exeto add the driver. But when I set up a linked server between MAS90 and SQL Server 2008 R2 I still get the architecture mismatch error. Just spoke to a guy from Sage and he says it won't work with 64-bit edition of Sql Server. The linked server works with MAS90 only if the edition of Sql Server is 32-bit.

我尝试C:\Windows\SysWOW64\odbcad32.exe添加驱动程序。但是当我在 MAS90 和 SQL Server 2008 R2 之间设置链接服务器时,我仍然收到架构不匹配错误。刚刚与 Sage 的一个人交谈,他说它不适用于 64 位版本的 Sql Server。链接服务器仅在 Sql Server 版本为 32 位时才与 MAS90 配合使用。

回答by TallTed

I'm betting you are working with User DSNs.

我敢打赌您正在使用用户 DSN。

Depending on your perspective, there's a "feature" or "bug" in the 64-bit Windows environment --

根据您的观点,64 位 Windows 环境中存在“功能”或“错误”——

  1. 32-bit User DSNs show up in the 64-bit Administrator and when 64-bit client applications ask for all available DSNs -- even though the 32-bit DSNs cannot be usedby the 64-bit client app and Adminstrator.

  2. 64-bit User DSNs show up in the 32-bit Administrator and when 32-bit client applications ask for all available DSNs -- even though the 64-bit DSNs cannot be usedby the 32-bit client app and Adminstrator.

  1. 32 位用户 DSN 显示在 64 位管理员中,当 64 位客户端应用程序请求所有可用的 DSN 时,即使64 位客户端应用程序和管理员无法使用32 位 DSN 。

  2. 64位用户dsn在32位管理员出现了,当32位客户端应用程序要求对所有可用DSN -即使64位的DSN不能使用的32位客户端应用程序和管理员联系。

The error message you describe comes up anytime there's such a bitness mismatch between the DSN and the client trying to work with it.

您描述的错误消息会在 DSN 和尝试使用它的客户端之间出现这种位不匹配时出现。

Microsoft's recommendation is to name your User DSNs with _32 or _64, depending on the bitness of the driver on which they're based ... or stick with System DSNs.

Microsoft 的建议是将您的用户 DSN 命名为 _32 或 _64,具体取决于它们所基于的驱动程序的位数……或者坚持使用系统 DSN。

There are 32-bit and 64-bit solutions for the connection you want. The bitness of your client application(s) -- IIS & PHP, in this case -- dictate the bitness of the solution you require.

对于您想要的连接,有 32 位和 64 位解决方案。您的客户端应用程序(在本例中为 IIS 和 PHP)的位数决定了您需要的解决方案的位数。

回答by kta

if 32 bit application on 64 bit operating system (the application you are installed under [program files (X86)] use the following C:\Windows\SysWOW64\odbcad32.exe

如果是 64 位操作系统上的 32 位应用程序(您安装在 [程序文件 (X86)] 下的应用程序,请使用以下 C:\Windows\SysWOW64\odbcad32.exe

otherwise 64 bit application and 64 bit operating system use the following C:\Windows\System32\odbcad32.exe

否则 64 位应用程序和 64 位操作系统使用以下 C:\Windows\System32\odbcad32.exe

otherwise you will get a error like "Architectural mismatch"

否则你会收到“架构不匹配”之类的错误

Hope this will save someone's day :)

希望这会拯救某人的一天:)

回答by David B

This worked for me: Updated solution, make sure the IIS application is NOT set to 32-bit on x64 Windows. More info: http://forum.gpsgate.com/topic.asp?TOPIC_ID=13711from:

这对我有用:更新的解决方案,确保 IIS 应用程序未在 x64 Windows 上设置为 32 位。更多信息:http: //forum.gpsgate.com/topic.asp?TOPIC_ID=13711来自:

http://forum.gpsgate.com/topic.asp?TOPIC_ID=13622

http://forum.gpsgate.com/topic.asp?TOPIC_ID=13622