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

Open Method (ADO Recordset) - ActiveX Data Objects (ADO) | Microsoft Docs

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.
Using powershell to write to an access database from a .csv file

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