Anders Pedersen
Anders Pedersen

Reputation: 1034

Can I open a MS access mdb file on CD with Delphi

Due to the MS Access database file generating a .ldb lock file when the .mdb file is open I get error trying running a Delphi application on CD where the database file also is on the CD.

Is there any solution for this problem?

Upvotes: 6

Views: 1377

Answers (1)

Michael Edenfield
Michael Edenfield

Reputation: 28338

Yes. You need to specify that you're opening the database in read-only mode. You didn't specify how you are opening the Access database, but for example, if you were using the ADODB COM objects, you would do something like this your your ADODB Connection object:

    conn.Provider := 'Microsoft.Jet.Oledb.4.0';
    conn.Mode := adShareDenyWrite;
    conn.Open('database.mdb');

Or within the connection string itself:

    conn.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;' + 
        'Data Source=database.mdb;' +
        'Mode=Share Deny Write';
    conn.Open;

Upvotes: 14

Related Questions