Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening a MS Access database from VB that is being used by another user

Is there a way to open a MS Access database from VB 6.0 that is being used by another user.

I have a service that is updating a .mdb file. I want to monitor this DB by reading some parameters from it periodically.

If I try to simply open the DB (which works if the DB is not used) like this:

Private Sub Form_Load()
Dim CurrentDBFileName
On Error GoTo ErrorHandler
    Set BaseDB = OpenDatabase("c:\temp\log_db.mdb")
    Set DestRS = BaseDB.OpenRecordset("current_log_info", dbOpenDynaset)
    DestRS.MoveFirst
    CurrentDBFileName = DestRS!CurrentDB
    BaseDB.Close
ErrorHandler:
    Debug.Print Err.Number; Err.Description
End Sub

The error I get:

3051 The Microsoft Jet database engine cannot open the file 'b:\log_db.mdb'. It is already opened exclusively by another user, or you need permission to view its data.

How can I get around this?

I can not change the service updating the MDB file since it is not mine.

like image 848
1qazxsw2 Avatar asked Dec 07 '25 18:12

1qazxsw2


1 Answers

Try:

Set BaseDB = OpenDatabase("gui_db.mdb", false)

To open the database in shared mode. Note that all clients must open the database in shared mode.

like image 67
Shiraz Bhaiji Avatar answered Dec 10 '25 18:12

Shiraz Bhaiji



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!