views:

343

answers:

5

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?

+2  A: 

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
an easy way to 'check' the mdac version is to open regedit and check HKEY_CLASSES_ROOT for MDACVer.Version.* tags
Stijn Sanders
and because detecting versions of MDAC is such a pain, head here http://support.microsoft.com/kb/301202 for help and tools.
fvu
Stijn Sanders
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
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
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
+1  A: 

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_
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
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_
"it regularly corrupted, to the point where we had to introduce a "repair" option of our own into the software" -- been there :)
onedaywhen
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
In my experience Access corruption generally happens when networks are intermittently flaky for a wide variety of reasons.
Tony Toews
+1  A: 

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
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
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
A: 

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
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
Did you check the read-only status of the mdb file on the problem PC?
_J_
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
If that's true, then I've just learned something myself. Thanks, Toby.
lkessler
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
+1  A: 

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
Will try that, thanks :)
Tofig Hasanov