mgas400
Goto Top

Löschabfrage MS Access als Task ausführen

Hallo zusammen,

ist es möglich eine Lösch- bzw. Hinzufügeabfrage in MS ACCESS 2010 per Task auszuführen?

Hintergrund ist das durch die Abfragen per ODBC Schnittstelle Dateien auf unserer IBM AS400 akutalisiert werden. --> Automatisiert wäre schöner als täglich einen Button drücken zu müssen.

Danke im Voraus


Grüße
MAXAS400

Content-Key: 311113

Url: https://administrator.de/contentid/311113

Printed on: April 25, 2024 at 06:04 o'clock

Member: Kraemer
Kraemer Jul 28, 2016 at 10:45:14 (UTC)
Goto Top
Moin,

Kombination aus Windows' geplante Aufgaben und dem hier sollte helfen.

Gruß Krämer
Mitglied: 129813
129813 Jul 28, 2016 updated at 10:55:16 (UTC)
Goto Top
Or a bit of Powershell or VBS
Powershell Version:
$conn = New-Object -Com 'ADODB.Connection'  
$conn.Open('Provider=Microsoft.ACE.OLEDB.12.0;Data Source = C:\Database1.accdb')  
$conn.Execute("Insert Into TableXYZ (COL1,COL2) VALUES ('VALUE1','VALUE2')")  
$conn.Close()
You can do it via the access db or directly via ADO without using the access db. That's your choice face-smile

Regards
Member: Kraemer
Kraemer Jul 28, 2016 at 10:57:56 (UTC)
Goto Top
Zitat von @129813:
> $conn = New-Object -Com 'ADODB.Connection'  
> $conn.Open('Provider=Microsoft.ACE.OLEDB.12.0;Data Source = C:\Database1.accdb')  
> $conn.Execute("Insert Into TableXYZ (COL1,COL2) VALUES ('VALUE1','VALUE2')")  
> $conn.Close()
> 
Wenn das wirklich funktioniert, ist das eine richtig schöne Lösung. Muss ich heute Abend mal testen.
Mitglied: 129813
Solution 129813 Jul 28, 2016 updated at 11:11:38 (UTC)
Goto Top
Zitat von @Kraemer:
Wenn das wirklich funktioniert, ist das eine richtig schöne Lösung. Muss ich heute Abend mal testen.
It does.
Important: Be sure to execute this with the x86 version of powershell if the OLEDB driver is installed only in x86 version (default)!! Or execute it via start-job with the parameter -RunAs32
Start-job -ScriptBlock {."C:\Folder\access_script.ps1"} -RunAs32  
Or wrap it directly inside the script
Start-Job -RunAs32 -ScriptBlock {
    $conn = New-Object -Com 'ADODB.Connection'  
    $conn.Open('Provider=Microsoft.ACE.OLEDB.12.0;Data Source = C:\Database1.accdb')  
    $conn.Execute("Insert Into TableXYZ (COL1,COL2) VALUES ('VALUE1','VALUE2')")  
    $conn.Close()
} | Receive-Job -Wait