最终用户计算机上的 C# 数据库访问需要 Microsoft Access 吗?
也许是个愚蠢的问题。
我在我的计算机上开发了一个应用程序,它使用 Microsoft Access 数据库 (.mdb) 来访问某些信息并使用 OLEDb 用监控数据填充表。
该应用程序在我的机器上运行良好,但是当我将版本放在测试机器上(没有 MS Access)时,它崩溃了。有趣的是,如果我要在测试计算机上启动刚刚重命名的数据库文件名的应用程序,它会像应该加载的那样加载,尽管没有数据。
我似乎抛出了 UnauthorizedAccessException 异常,这进一步让我感到困惑。
开发机器和我正在测试它的机器都安装了.NET 3.5。
我预计我的问题会得到大量“不”的回答,但到底是什么 - 测试机器是否需要安装 MS Access?
问候
Silly question, perhaps.
I've developed an app on my machine that uses a Microsoft Access database (.mdb) to access certain information and populate a table with monitoring data using OLEDb.
The application works fine on my machine, but when I put the release on test machines (without MS Access), it crashes. Interestingly, if I were to launch the application on the testing machine with the database filename just renamed, it loads like it should albeit without the data.
I seem to get an UnauthorizedAccessException exception thrown which further clouds my confusion.
Both the development machine and the machine I'm testing it on have .NET 3.5 installed.
I would expect a barage of 'No's in reply to my question, but what the heck - does the testing machine need to have MS Access installed?
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
尝试下载 Office 连接组件 在这里。这将允许您在不安装 Access 的情况下读取和创建 Access 数据库。
Try downloading the Office Connectivity Components here. This will let you read and create Access databases without having Access installed.
它不需要 MS Access,但您需要您的 Access 版本所需的驱动程序。您可能需要进行测试发布,将确切的异常和消息输出到日志。
It doesn't need MS Access but you will need the required driver for your version of Access. You may need to do a test release that outputs to a log the exact Exception and message.
确保您安装了最新的 Jet 4 OLEDB 驱动程序。如果您从网络共享运行应用程序(然后它以受限的权限运行),也可能会出现问题。
Make sure you have latest Jet 4 OLEDB drivers installed. There might also be a problem if you run the application from a network share (then it runs with restricted rights).
您说您遇到了 UnauthorizedAccessException。我首先检查 .mdb 文件和位置的读/写权限。
如果您作为服务运行,请记住它们在更受限制的帐户下运行。
You say you got an UnauthorizedAccessException. I'd check read/write permissions to the .mdb file and location first.
If you're running as a service remember that they run under more restricted accounts.
您不需要 Access 本身。您需要拥有至少与开发机器上的 JET 驱动程序和关联文件一样最新的文件 - 如果您回收旧机器用于测试,则可能会出现问题。
然而,这听起来确实像是一个权限问题,无论是在数据库文件本身还是在文件内部(如果您使用的是 Access 的安全机制)。
You don't need Access itself. You will need to have JET drivers and associated files at least as current as the ones on your development machine — if you're recycling an old machine to use for testing that could be the problem.
However, this really sounds like a permissions issue, either on the database file itself or inside the file if you're using Access's security mechanisms.
事实证明,问题是硬件问题。当我使用的卡上的一个串行端口被移动到一台新机器时,它已经被占用。
事实证明,问题与数据库无关,正如异常所暗示的那样。
不过,提出了一些关于 JET 的有趣观点,这对于任何有数据库访问问题的人来说可能很有用。
谢谢你们的帮助。
It turns out the issue was a hardware problem. One of the serial ports on the card I was using had gone capput when it got moved to a new machine.
Turns out the problem wasn't database related, as the exception would've suggested.
Some interesting points on JET were raised though, which could be useful to anyone with Database access issues.
Thanks for your help guys.