Bug 158056 - Connect to MS Access *.mdb files by mean of Microsoft.ACE.OLEDB.12.0 provider
Summary: Connect to MS Access *.mdb files by mean of Microsoft.ACE.OLEDB.12.0 provider
Status: ASSIGNED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All Windows (All)
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: target:24.8.0
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-03 19:07 UTC by jcsanz
Modified: 2024-04-19 03:16 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
Sample database (284.00 KB, application/msaccess)
2023-11-03 21:04 UTC, jcsanz
Details
Test database format .accdb (312.00 KB, application/msaccess)
2024-04-03 20:28 UTC, jcsanz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jcsanz 2023-11-03 19:07:47 UTC
Description:
Base, in Windows OS, has two specific options to connect to MS Access databases: "Microsoft Access" and "Microsoft Access 2007".

In order to use these connections, the corresponding database engines must be installed on the system.

The "Microsoft Access" connection uses the "Microsoft.Jet.OLEDB.4.0" engine as data provider. This engine was used to connect to *.mdb databases and was installed with certain versions of MS Access. Also it was available for download and installation on Microsof's web pages, although for some time now, this engine is no longer available for download on these pages.

The "Microsoft Access 2007" connection uses the "Microsoft.ACE.OLEDB.12.0" provider. Although there is already a newer version, this provider can be obtained from Microsoft's pages by downloading and installing the "Microsoft Access Database Engine 2010 Redistributable".

Although the Jet.OLEDB.4.0 engine is not readily available, a connection to *.mdb files can be established via the "Microsoft.ACE.OLEDB.12.0" provider used by the "Microsoft Access 2007" connection, however, if in the database wizard the "Microsoft Access 2007" connection is selected, it does not allow to select *.mdb files because the pattern is set for *.accdb files only.

To achieve this improvement it should be done:
- Remove the connection that is made via the Jet.OLEDB.4.0 provider.
- Rename the connection made with the ACE.OLEDB.12.0 engine (probably to "Microsoft Access" without "2007").
- Extend the pattern of this last connection so that *.mdb files can be opened.

Another alternative would be:
- Keep the connection to the Jet.OLEDB.4.0 engine (in case some user still has this engine)
- Rename the connection "Microsoft Access 2007", for example to "Microsof Access OLEDB.12" so that it does not specify the version of the file type but the engine used.
- Add to this connection the *.mdb pattern to be able to open this type of files.

Steps to Reproduce:
See description

Actual Results:
Connection to *.mdb files can not be established without Jet.OLEDB.4.0 engine (not available)

Expected Results:
Establish connection to *.mdb files with ACE.OLEDB.12.0 engine


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 7.6.2.1 (X86_64) / LibreOffice Community
Build ID: 56f7684011345957bbf33a7ee678afaf4d2ba333
CPU threads: 16; OS: Windows 10.0 Build 22621; UI render: Skia/Vulkan; VCL: win
Locale: es-ES (es_ES); UI: es-ES
Calc: CL threaded
Comment 1 jcsanz 2023-11-03 21:04:52 UTC Comment hidden (obsolete)
Comment 2 jcsanz 2023-11-03 21:06:05 UTC
As you can deduce from my previous exposition, to be able to connect to the database it is required to have installed the data provider "Microsoft.ACE.OLEDB.12.0".

The steps to follow to verify that you can establish the connection with the *.mdb files are the following (you can use the attached example database):
    1. If you do not have the provider installed, download and install the package "Microsoft Access Database Engine 2010 Redistributable" 2.
    2. Open Base to create a new database
    3. In the database wizard, select "Connect to an existing database" and in the drop-down list, select "Microsoft Access 2007". Click on "Next2
    4. In the second step, click on the "Browse" button.
    5. In the text box type "*.mdb" (without the quotes) and press "Enter" to make the file explorer display the *.mdb files.
    6. Browse to find and select the *.mdb file and click on the "Open" button.
    7. Click on "Finish" and give a name to the .ODB file.		

An additional check that can be made to find out which data providers are installed is to use the ADO connection (actually, Base uses ADO internally to connect to Access databases):
    Open Base to create a new database 2.
    2. In the database wizard, select "Connect to an existing database" and in the drop-down list, select "ADO".
    3. In the second step of the database wizard click on the "Browse" button.
    4. A window will appear with a list box with the installed data providers, among them, if we have installed the "Microsoft Access Database Engine 2010 Redistributable", we will have "Microsoft Office 12.0 Access Database Engine OLE DB Provider" which is the one used for the "Microsoft Access 2007" connection.
    5. In the unlikely event that you have "Microsoft.Jet.OLEDB.4.0" installed, it will also appear in this list. If you have installed a modern version of Access or have installed the "Microsoft Access Database Engine 2016 Redistributable", you also have the "Microsoft Office 16.0 Access Database Engine OLE DB Provider".
Comment 3 jcsanz 2023-11-03 21:07:15 UTC Comment hidden (obsolete)
Comment 4 jcsanz 2024-04-03 14:59:50 UTC
Summary of current status
* Currently to connect to MS Access .mdb files you need the "Microsoft.Jet.OLEDB.4.0" provider.
* The "Microsoft.Jet.OLEDB.4.0" provider needs to be installed on the computer to use it.
* The connector "Microsoft.Jet.OLEDB.4.0" is not available on the Microsoft download pages for some time now
* You can connect to both .mdb and more modern .accdb files via the "Microsoft.ACE.OLEDB.12.0" provider, but Base is only prepared to use this provider with .accdb files.
* The "Microsoft.ACE.OLEDB.12.0" provider also needs to be installed, but it is still possible to download an installer from the Microsoft pages.

Proposed solution
* Modify the code so that all connections to MS Access files, both .mdb and .accdb are made with the provider "Microsoft.ACE.OLEDB.12.0".
* Remove all references to the "Microsoft.Jet.OLEDB.4.0" provider to clean up the code.
* Leave only one entry "Microsoft Access" in the Connection Wizard, which would work for .mdb and .accdb files.
* Remove the entry "Microsoft Access 2007" from the Connection Wizard, since it is no longer needed.
Comment 5 jcsanz 2024-04-03 20:28:41 UTC
Created attachment 193471 [details]
Test database format .accdb
Comment 6 jcsanz 2024-04-03 20:29:57 UTC
Comment on attachment 193471 [details]
Test database format .accdb

Test database in Access 2007 format
Comment 7 Commit Notification 2024-04-18 14:19:52 UTC
jucasaca committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7edca7dc740f6877fa85c2a996ca869c6b971a48

tdf#158056 Connect to MS Access .mdb files by mean of ACE.OLEDB.12.0 provider

It will be available in 24.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.