从 Delphi 7 打开 Access 数据库时出现问题
我正在开发Delphi 7应用程序,它使用Access数据库(MDB格式)运行。它在我的电脑和其他一些电脑上运行良好。但在某些机器上,应用程序有时在尝试访问数据库时会出现错误,显示“未知的数据库格式(mdb)”之类的内容。另外我注意到一件事:当您使用 Office 在 Ms Access 中打开该数据库时,由于某种原因它会以“只读”模式打开。有人可以帮忙吗?问题的原因可能是什么?
I am developing Delphi 7 application, which is operating with Access Database (MDB format). It works fine on my PC, and some other PCs as well. But on some machines application gives error when trying to access database sometimes, saying something like "Unkown database format (mdb)". Additionally I noticed one thing: When you open that database in Ms Access using Office, it is opened in "read-only" mode for some reason. Can anybody help? What could be the reason for the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我已经很久没有使用 Delphi 编程了,但我记得安装的不同版本的 MDAC 时遇到了问题。比较可以运行的电脑和不能运行的电脑之间的版本。
It's been a long time since I have programed in Delphi, but I remember I had issues with different versions of MDAC installed. Compare the versions between the pc's that work and those that don't.
我认为您最有可能的问题与 MDAC 有关,使用注册表检查每台计算机上的版本,看看有效版本和无效版本之间是否存在差异。
I think your most likely problem is to do with MDAC, use the registry to check what version is on each machine and see if there is a differnce between the ones that work and the ones that dont.
如果数据库文件(mdb 文件)实际上设置为只读(例如,如果它是从 CD 上复制的),我常常会收到该错误消息。检查 Windows 资源管理器中的文件属性并确保该文件不是只读的。
另外,您是否尝试过制作紧凑型和紧凑型?在 Access 中进行修复,因为 Access 数据库经常损坏,此选项通常会导致各种问题。
I used to get that error message if the database file (the mdb file) was actually set to read-only (for example, if it had been copied off a CD). Check the file properties in Windows Explorer and ensure the file isn't read-only.
Also, have you tried doing a Compact & Repair within Access, as Access databases regularly corrupt and this option can often help cause all manner of problems.
MDB 是针对哪个版本的 Access 进行格式化的?您是否使用 DAO 或 ADO 来访问数据库? MDB是2003年还是2007年?我怀疑它是 A2007 格式,而您遇到问题的计算机安装了 A2003 或根本没有 Access 版本。而可以运行的机器上确实安装了 A2007。但这只是一个猜测。
您还需要找出只读问题。
What version of Access is the MDB formatted for? Are you using DAO or ADO to access the databases. Is the MDB in 2003 or 2007? I suspect it's in A2007 format and the machines you are having troubles with have A2003 installed or no version of Access at all. Whereas the machines that work do have A2007 installed on them. But that's just a guess.
You also need to track down the read only problem too.
您说:“它在我的电脑上运行良好,在其他一些电脑上也运行良好。”
那么听起来你的程序可能没有任何问题。可能是因为它无法一直运行的 PC 没有安装 Microsoft Office 或至少没有安装 Microsoft Access。他们需要安装 Access 才能使 ADO 工作。
如果没有进一步的线索,机器上的“有时”问题很难诊断。
恐怕我不知道“只读”问题可能是什么。
You say: "It works fine on my PC, and some other PCs as well."
Then it sounds like there might not be anything wrong with your program. What it could be is that the PCs it won't work on all the time do not have Microsoft Office or at least Microsoft Access installed. They need to have Access installed for ADO to work.
A "sometimes" problem on a machine is difficult to diagnose without further clues.
I'm afraid I don't know what the "Read-only" problem might be.