0

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?

Toby Allen
  • 10,997
  • 11
  • 73
  • 124
Tofig Hasanov
  • 3,303
  • 10
  • 51
  • 81

5 Answers5

2

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.

ptutt
  • 1,338
  • 3
  • 18
  • 35
  • an easy way to 'check' the mdac version is to open regedit and check HKEY_CLASSES_ROOT for MDACVer.Version.* tags – Stijn Sanders Oct 22 '09 at 13:03
  • and because detecting versions of MDAC is such a pain, head here http://support.microsoft.com/kb/301202 for help and tools. – fvu Oct 22 '09 at 13:04
  • if MDACVer.Version.2.81 isn't there: [upgrade][1] [1]: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=78cac895-efc2-4f8e-a9e0-3a1afbd5922e – Stijn Sanders Oct 22 '09 at 13:04
  • Jet has not been included in MDAC for a very long time, for the very obvious reason that you don't need to distribute what is already installed on every copy of Windows (i.e., starting with Win2000, Jet is included as an OS component, and maintained via Windows Update). – David-W-Fenton Oct 23 '09 at 01:24
  • I have Access 2007, but the file is Access 2000 file (I selected the oldest possible file format). Computers which have this problem have Access installed as well (not neccesarily the same version as me). – Tofig Hasanov Oct 23 '09 at 06:10
  • If this is the cause of the problem, how should I change the program so that it can work on all clients' machines? I can't tell them to upgrade MDAC as they won't be able to – Tofig Hasanov Oct 23 '09 at 06:12
1

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.

J__
  • 3,777
  • 1
  • 23
  • 31
  • 1
    Jet/ACE databases do *not* regularly corrupt, unless you're mistreating them and not using Jet/ACE in an appropriate manner. -1 – David-W-Fenton Oct 23 '09 at 01:25
  • I beg to differ. We used Access as our software database for nearly 10 years and it regularly corrupted, to the point where we had to introduce a "repair" option of our own into the software. I appreciate your point of view and know that you have also a great deal of experience with Access, but it is not down to mistreatment, simply a fact when it is used a great deal. – J__ Oct 23 '09 at 07:50
  • "it regularly corrupted, to the point where we had to introduce a "repair" option of our own into the software" -- been there :) – onedaywhen Oct 23 '09 at 09:29
  • Q1. How do you know if you are mistreating the Access Database Engine? A1. It goes corrupt. Q2. How does one avoid corruption? A2. Don't mistreat it. Repeat as necessary. – onedaywhen Oct 23 '09 at 09:31
  • In my experience Access corruption generally happens when networks are intermittently flaky for a wide variety of reasons. – Tony Toews Oct 24 '09 at 19:01
1

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.

Tony Toews
  • 7,850
  • 1
  • 22
  • 27
  • You dont need MSAccess to be installed to use an .mdb file as your database, you simply need to have MDAC installed and use ADO to connect. – Toby Allen Oct 24 '09 at 07:09
  • Toby: Or you can use DAO as it comes with Windows 2000, XP, Vista and 7 operating systems. (I assume Delphi also supports DAO.) – Tony Toews Oct 24 '09 at 18:59
1

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.

Toby Allen
  • 10,997
  • 11
  • 73
  • 124
-1

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.

lkessler
  • 19,819
  • 36
  • 132
  • 203
  • I have Access 2007, but the file is Access 2000 file (I selected the oldest possible file format). Computers which have this problem have Access installed as well (not neccesarily the same version as me). – Tofig Hasanov Oct 23 '09 at 06:12
  • Did you check the read-only status of the mdb file on the problem PC? – J__ Oct 23 '09 at 07:51
  • Sorry that is just wrong, you do not need Access installed to use MDB file you just need MDAC (freely downloaded from Microsoft). Very few machines ever have access installed. – Toby Allen Oct 24 '09 at 07:10
  • If that's true, then I've just learned something myself. Thanks, Toby. – lkessler Oct 24 '09 at 15:13
  • Toby, you are correct in that Access is not required. However neither is MDAC. Assuming that Delphi supports DAO you can use it as well as Jet 4.0 comes with Windows 2000, XP, Vista and 7 operating systems. And there's no concerning yourself with MDAC versions. – Tony Toews Oct 24 '09 at 19:03