I have Office installed by the OLEDB provider "Microsoft.ACE.OLEDB.15.0;" is not registered (I cannot see it from the list from the powershell attached below)
However, in Excel VBA, I can create and connect to a data source with this ACE provider in the connection string.
Sub test()
Dim con As New ADODB.Connection
Dim database As String, AccessConnect_ACE As String
database = "C:\temp\test.mdb"
AccessConnect_ACE = "Provider=Microsoft.ACE.OLEDB.15.0;" & _
"Data Source=" & database & ";"
con.ConnectionString = AccessConnect_ACE
con.Open
End Sub
but a very similiar python script does not work
import adodbapi
database = "D:\\test\\test.mdb"
constr = 'Provider=Microsoft.ACE.OLEDB.15; Data Source=%s' % database
conn = adodbapi.connect(constr)
What is the reason?
PS: The powershell script to list registered providers
function Get-OledbRegistered
{
[CmdletBinding()]
[OutputType([System.Collections.Generic.List[PSObject]])]
param ()
Process
{
$list = New-Object ([System.Collections.Generic.List[PSObject]])
foreach ($provider in [System.Data.OleDb.OleDbEnumerator]::GetRootEnumerator())
{
$v = New-Object PSObject
for ($i = 0; $i -lt $provider.FieldCount; $i++)
{
Add-Member -in $v NoteProperty $provider.GetName($i) $provider.GetValue($i)
}
Write-Host "$v"
Write-Host "111"
$list.Add($v)
}
return $list
}
}
Get-OledbRegistered
Are you sure that the Powershell runs in 32bit as you Excel my do?
So maybe the OLEDB provider exists in 32bit but not for 64bit. Install the SCE pack for 64bit too!