当安装程序未创建标准 DSN 时,如何在 64 位 Server 2008 上使用 32 位 ODBC 驱动程序?

发布于 2024-07-27 13:38:21 字数 742 浏览 3 评论 0原文

我遇到了一些第三方软件的问题,我们使用这些软件来跟踪计算机实验室中的软件许可证使用情况。 在收到该公司的兼容性保证并运行一些初步测试表明该应用程序可以在 64 位环境中运行后,我们最近将该应用程序迁移到了 64 位 Server 2008。 不幸的是,进行测试的人没有测试我拥有的几个应用程序的功能,这些应用程序依赖于访问数据来对数据进行实时和后处理以生成一些报告。

事实证明,该应用程序没有 64 位 ODBC 驱动程序来访问其内部数据,并且无法使用 64 位 SQL Server ODBC 驱动程序将其数据导出到 SQL Server。 它确实包含并安装了 32 位 ODBC 驱动程序,但它将其安装为用户数据源,而不是系统数据源,这意味着运行实时集合的 Windows 服务无法找到它。 我也无法创建系统 DSN,因为数据源管理控制台找不到已安装的驱动程序。

我的问题是如何为此连接配置数据源,以便我可以从系统帐户下运行的 C#/.NET Windows 服务访问该数据源?

既然我已经找到了一种方法,我将提供我的解决方案作为答案(与关于如何回答你自己的问题)。

如同: 有哪些软件可以将 64 位 ODBC 应用程序桥接到 Windows 上的 32 位 ODBC 驱动程序?

I ran into an issue with some third party software that we use to track software license usage in our computer labs. We recently migrated the app to 64-bit Server 2008 after receiving assurances from the company that it was compatible and running some preliminary tests that showed that the app worked in the 64-bit environment. Unfortunately the person doing the testing didn't test the functionality of a couple of apps that I have that rely on accessing the data to do both live- and post-processing on the data to produce some reports.

Turns out that the application doesn't have a 64-bit ODBC driver to access its internal data and can't use a 64-bit SQL Server ODBC driver to export its data to SQL server. It does include and install a 32-bit ODBC driver, but it installs it as a User Data Source, not a System Data Source, meaning that my windows service that runs the live collection isn't able to find it. I'm also not able to create a System DSN since the Data Sources admin console can't find the installed driver.

My question is how do I configure a data source for this connection that I can access from a C#/.NET windows service running under a system account?

Since I've figured out a way to do it, I'll provide my solution as an answer (in keeping with the FAQ on how to answer your own question).

Similar to:
What software exists for bridging a 64-bit ODBC app to a 32-bit ODBC driver on windows?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

策马西风 2024-08-03 13:38:21

事实证明,您可以使用 C:\Windows\SysWOW64\odbcad32.exe 创建 32 位 ODBC 连接。 我的解决方案是创建 32 位 ODBC 连接作为系统 DSN。 这仍然不允许我连接到它,因为 .NET 无法查找它。 在寻找如何让 OdbcConnection 类在正确的位置查找 DSN 的大量搜索后,我偶然发现了一个网站,该网站建议修改注册表以解决​​不同的问题。

我最终直接在 HKLM\Software\ODBC 下创建了 ODBC 连接。 我在 SysWOW6432 项中查找了使用 32 位版本的 ODBC 管理工具设置的参数,并在标准位置重新创建了该参数。 但是,我没有添加驱动程序的条目,因为该应用程序的标准安装程序也没有安装该驱动程序。

(手动)创建条目后,我启动了 Windows 服务,一切都很顺利。

It turns out that you can create 32-bit ODBC connections using C:\Windows\SysWOW64\odbcad32.exe. My solution was to create the 32-bit ODBC connection as a System DSN. This still didn't allow me to connect to it since .NET couldn't look it up. After significant and fruitless searching to find how to get the OdbcConnection class to look for the DSN in the right place, I stumbled upon a web site that suggested modifying the registry to solve a different problem.

I ended up creating the ODBC connection directly under HKLM\Software\ODBC. I looked in the SysWOW6432 key to find the parameters that were set up using the 32-bit version of the ODBC administration tool and recreated this in the standard location. I didn't add an entry for the driver, however, as that was not installed by the standard installer for the app either.

After creating the entry (by hand), I fired up my windows service and everything was happy.

叹梦 2024-08-03 13:38:21

打开IIS管理器,选择应用程序池,选择您正在使用的应用程序池,单击右侧菜单中的高级设置。 在“常规”下,将“启用 32 位应用程序”设置为“True”。

Open IIS manager, select Application Pools, select the application pool you are using, click on Advanced Settings in the right-hand menu. Under General, set "Enable 32-Bit Applications" to "True".

戒ㄋ 2024-08-03 13:38:21

其中很多答案都很旧,所以我想我会用我认为有用的解决方案进行更新。

我们的问题与 OP 类似,我们将 32 位 XP 计算机升级到 64 位 Windows 7,并且使用 32 位 ODBC 驱动程序的应用程序软件无法写入数据库。

结果是,有两个 ODBC 数据源管理器,一个用于 32 位,一个用于 64 位。 所以我必须运行 C:\Windows\SysWOW64\odbcad32.exe 中的 32 位版本。 在 ODBC 数据源管理器中,我可以转到“系统 DSN”选项卡并使用“添加”按钮将我的驱动程序添加到列表中。 (您可以检查“驱动程序”选项卡以查看可以添加的驱动程序列表,如果您的驱动程序不在该列表中,则可能需要安装它)。

下一个问题是我们运行的软件被编译为使用“任何 CPU”。 这将看到操作系统是 64 位,因此它将查看 64 位 ODBC 数据源。 因此,我必须强制程序编译为 x86 程序,然后告诉它查看 32 位 ODBC 数据源。 要将程序设置为 x86,请在 Visual Studio 中转到项目属性,在顶部的构建选项卡下有一个平台下拉列表,然后选择 x86。 如果您没有源代码并且无法将程序编译为 x86,您可以右键单击程序 .exe,然后转到兼容性选项卡并选择适合您的兼容性。

添加驱动程序并且程序指向正确的驱动程序后,一切都像以前一样工作。 希望这可以帮助任何使用旧软件的人。

A lot of these answers are pretty old, so I thought I would update with a solution that I think is helpful.

Our issue was similar to OP's, we upgraded 32 bit XP machines to 64 bit windows 7 and our application software that uses a 32 bit ODBC driver stopped being able to write to our database.

Turns out, there are two ODBC Data Source Managers, one for 32 bit and one for 64 bit. So I had to run the 32 bit version which is found in C:\Windows\SysWOW64\odbcad32.exe. Inside the ODBC Data Source Manager, I was able to go to the System DSN tab and Add my driver to the list using the Add button. (You can check the Drivers tab to see a list of the drivers you can add, if your driver isn't in this list then you may need to install it).

The next issue was the software that we ran was compiled to use 'Any CPU'. This would see the operating system was 64 bit, so it would look at the 64 bit ODBC Data Sources. So I had to force the program to compile as an x86 program, which then tells it to look at the 32 bit ODBC Data Sources. To set your program to x86, in Visual Studio go to your project properties and under the build tab at the top there is a platform drop down list, and choose x86. If you don't have the source code and can't compile the program as x86, you might be able to right click the program .exe and go to the compatibility tab and choose a compatibility that works for you.

Once I had the drivers added and the program pointing to the right drivers, everything worked like it use to. Hopefully this helps anyone working with older software.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文