SQL Server DSN-Less ODBC指定32位驱动程序

时间:2022-12-13 04:35:11

I'm working with an older application that I recently updated to .NET 4.5. The application has been using DSN ODBC connections. However, in the case of the application, it is accessed from a single location on a network drive, so it doesn't make sense to require a DSN, and it will ease deployment and updates to use a DSN-less connection string in place. I'm doing a basic string as such:

我正在使用我最近更新到.NET 4.5的旧应用程序。该应用程序一直在使用DSN ODBC连接。但是,对于应用程序,它是从网络驱动器上的单个位置访问的,因此要求DSN没有意义,并且它将简化部署和更新以使用无DSN连接字符串到位。我正在做一个基本的字符串:

Driver={SQL Server}; Server=; Database=; UID=; PWD=

The issue I have is that the application is compiled as 32 bit, but may be used on a 32 bit or 64 bit machine. On 64 bit machines I get this error:

我遇到的问题是应用程序编译为32位,但可以在32位或64位计算机上使用。在64位机器上我收到此错误:

The specified DSN contains an architecture mismatch between the Driver and Application

指定的DSN包含驱动程序和应用程序之间的体系结构不匹配

Which essentially means it's trying to use the 64 bit driver for the 32 bit application. That's easy enough to deal with except the driver name for SQL Server appears to be the same for 32 and 64 bit. So how can I specify only the 32 bit driver in the connection string?

这实际上意味着它正在尝试将64位驱动程序用于32位应用程序。这很容易处理,除了SQL Server的驱动程序名称对于32位和64位似乎是相同的。那么如何在连接字符串中仅指定32位驱动程序?

1 个解决方案

#1


4  

"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. In Administrative Tools on a 64-bit Windows 8 operating system, there are icons for both the 32-bit and 64-bit ODBC Data Source Administrator dialog box. Read more"

“要管理连接到64位平台下的32位驱动程序的数据源,请使用c:\​​ windows \ sysWOW64 \ odbcad32.exe。要管理连接到64位驱动程序的数据源,请使用c:\ windows \ system32 \ odbcad32.exe。在64位Windows 8操作系统上的“管理工具”中,“32位和64位ODBC数据源管理器”对话框都有图标。阅读更多“

If you use the 64-bit odbcad32.exe to configure or remove a DSN that connects to a 32-bit driver, you will receive the following error message:

如果您使用64位odbcad32.exe配置或删除连接到32位驱动程序的DSN,您将收到以下错误消息:

The specified DSN contains an architecture mismatch between the Driver and Application

指定的DSN包含驱动程序和应用程序之间的体系结构不匹配

To resolve this error, use the 32-bit odbcad32.exe to configure or remove the DSN.

要解决此错误,请使用32位odbcad32.exe配置或删除DSN。

References

参考


Side Note: make sure that all references Copy Local property is set to True, even the System assemblies. I think that the issue may be from the assemblies location saved in GAC, so when copying the assemblies locally it may fix that

侧注:确保所有引用Copy Local属性都设置为True,甚至是系统程序集。我认为问题可能来自GAC中保存的程序集位置,因此在本地复制程序集时可能会解决这个问题

#1


4  

"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. In Administrative Tools on a 64-bit Windows 8 operating system, there are icons for both the 32-bit and 64-bit ODBC Data Source Administrator dialog box. Read more"

“要管理连接到64位平台下的32位驱动程序的数据源,请使用c:\​​ windows \ sysWOW64 \ odbcad32.exe。要管理连接到64位驱动程序的数据源,请使用c:\ windows \ system32 \ odbcad32.exe。在64位Windows 8操作系统上的“管理工具”中,“32位和64位ODBC数据源管理器”对话框都有图标。阅读更多“

If you use the 64-bit odbcad32.exe to configure or remove a DSN that connects to a 32-bit driver, you will receive the following error message:

如果您使用64位odbcad32.exe配置或删除连接到32位驱动程序的DSN,您将收到以下错误消息:

The specified DSN contains an architecture mismatch between the Driver and Application

指定的DSN包含驱动程序和应用程序之间的体系结构不匹配

To resolve this error, use the 32-bit odbcad32.exe to configure or remove the DSN.

要解决此错误,请使用32位odbcad32.exe配置或删除DSN。

References

参考


Side Note: make sure that all references Copy Local property is set to True, even the System assemblies. I think that the issue may be from the assemblies location saved in GAC, so when copying the assemblies locally it may fix that

侧注:确保所有引用Copy Local属性都设置为True,甚至是系统程序集。我认为问题可能来自GAC中保存的程序集位置,因此在本地复制程序集时可能会解决这个问题