powershell add row to access mdb file

Hi all,

 

I’m trying on my win 7 pc to make a powershell script that adds a row to a access mdb file.(office 2013 32 bit).

But it fails every time, I have already install AccessDatabaseEngine.exe but without success, my code and the error:

$Ado = New-Object -ComObject ADODB.Connection 

$recordset = New-Object -ComObject ADODB.Recordset$Ado.Open("Provider = Microsoft.ACE.OLEDB.12.0;Data Source=d:\test.mdb");

Maar dan krijg ik : Exception calling “Open” with “1” argument(s): "Kan de voorziening niet vinden. Mogelijk is deze niet juist geïnstalleerd."At D:\importinaccess.ps1:28 char:12+ $Ado.Open <<<< (“Provider = Microsoft.ACE.OLEDB.12.0;Data Source=d:\test.mdb”)+ CategoryInfo : NotSpecified: (:slight_smile: [], MethodInvocationException

 

Can someone help me please?

Kind regards

Open() Method requires 4 inputs, please see

https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/open-method-ado-recordset?view=sql-server-2017

You can get this via PowerShell

$Ado = New-Object -ComObject ADODB.Connection 
$recordset = New-Object -ComObject ADODB.Recordset
$Ado.Open

OverloadDefinitions
-------------------
void Open (string, string, string, int)

I have never used this, hence I don’t have a working example of the same.

How about the code at the bottom here? It inserts rows from a csv.
https://social.technet.microsoft.com/Forums/windowsserver/en-US/54d10209-9d24-49bb-84e8-389deb452050/using-powershell-to-write-to-an-access-database-from-a-csv-file?forum=winserverpowershell

Hi , thanks for your input.

 

The problem was that i use an 32bit office, but powershell was 64bit.

If i run powershell 32bit, it works :slight_smile:

 

thx