简体   繁体   中英

How to access mdb file in windows10 by powershell?

Following the suggestion that shown in the following link, I have created a powershell script to access the mdb file.

https://devblogs.microsoft.com/scripting/hey-scripting-guy-can-i-query-a-microsoft-access-database-with-a-windows-powershell-script/

which is:

    $cn = new-object -comobject ADODB.Connection
    $rs = new-object -comobject ADODB.Recordset
    $cn.Open("Provider = Microsoft.Jet.OLEDB.4.0;Data Source = $path")

However, i have updated my computer to windows 10 (64bit) and installed ACCESS 2016. The powershell script does not working anymore. And it shows that the Provider = Microsoft.Jet.OLEDB.4.0 is not found.

I have tried to change the Provider = Microsoft.ACE.OLEDB.12.0 But it does not help, as it shows the same error that the provider is not found.

Moreover, I have tried to open it with ACCESS 2016, it also does not help as it shows that can not open the database file that created in previous version.

Please help....

Thanks for whom reply my question. Finally I got insight and find the answer myself.

I search the provider from Microsoft and find the link below. https://www.microsoft.com/en-us/download/details.aspx?id=13255

After install the 64bit version, I can use the following code with the Microsoft.ACE.OLEDB.12.0 provider.

$cn = new-object -comobject ADODB.Connection
$rs = new-object -comobject ADODB.Recordset
$cn.Open("Provider = Microsoft.ACE.OLEDB.12.0;Data Source = $path")

If Win 10 OS 64 bits with MS Office 32bits / click2run, use 32bits Powershell;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM