OLEDB 连接使用无需物理安装驱动程序 [英] OLEDB Connection using without physically installing the driver

查看:46
本文介绍了OLEDB 连接使用无需物理安装驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试访问驻留在我机器上的 MS Access 数据库文件,当我安装了 office 时它工作得很好.

当我尝试在没有安装 office/驱动程序的机器上使用相同的代码时,它抛出错误Microsoft.ACE.OLEDB.12.0 提供程序未注册">

我跟进了这篇文章 Microsoft.ACE.OLEDB.12.0 提供程序未注册,但这里的解决方案是物理安装可再发行组件.而我想使用 C# 以编程方式进行安装.

是否只能通过物理安装才能实现,这是唯一的出路吗?

解决方案

如果您的应用程序使用 Microsoft.ACE.OLEDB.12.0 驱动程序,则必须在计算机上安装该驱动程序.要(直接)使用 C# 以编程方式"访问数据库文件,本质上需要您(重新)编写 JackcessC#.这将是巨大的工作量,并且没有任何实际意义(因为适用于 Windows 的适当 ACE.OLEDB 驱动程序已经免费提供).

另一种方法是改用 Microsoft.Jet.OLEDB.4.0 驱动程序.(32 位)Jet 驱动程序随 Windows 的每个副本安装.但是,您将面临以下限制:

  1. 您的应用程序只能操作 .mdb 文件,而不能操作 .accdb 文件,并且
  2. 您的应用程序必须构建为 32 位应用程序.

I have been trying to access the MS Access database file residing on my machine and it works just fine when I have office installed.

When I try to use the same code on a machine that does not have office installed/driver installed it throws up an error "Microsoft.ACE.OLEDB.12.0 provider is not registered"

I followed up on this post Microsoft.ACE.OLEDB.12.0 provider is not registered but the solution here is to install the redistributable physically.while I would like to do it programmatically using C#.

Would that be possible only by installation physically, is this the only way out?

解决方案

If your application uses the Microsoft.ACE.OLEDB.12.0 driver then that driver must be installed on the machine. To (directly) access the database file "programmatically using C#" would essentially involve you (re-)writing Jackcess in C#. That would be a huge amount of work and would make no real sense (since the proper ACE.OLEDB driver for Windows is already freely available).

One alternative would be to use the Microsoft.Jet.OLEDB.4.0 driver instead. The (32-bit) Jet driver is installed with every copy of Windows. However, you would face the following restrictions:

  1. Your application would only be able to manipulate .mdb files, not .accdb files, and
  2. Your application would have to be built as a 32-bit application.

这篇关于OLEDB 连接使用无需物理安装驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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