我尝试通过运行Powershell的查询来更新MS Access表。我将代码简化如下:
Write-Host "Start Access ..."
$Acc = New-Object –com Access.Application
Write-Host "Open database ..."
$Acc.OpenCurrentDataBase("C:\Users\Administrator\Documents\redacted\imh-test.accdb")
Write-Host "connected ..."
$Acc.DoCmd.RunSQL("update DeepcleanEntryDoor set Title = 'Mrs'")
Write-Host "Data appended, close Access ..."
$Acc.Quit()
Write-Host "... process complete!"
我得到了#34; RunSQL操作被取消了。"如下:
Start Access ...
Open database ...
connected ...
Exception calling "RunSQL" with "1" argument(s): "The RunSQL action was canceled."
At line:8 char:1
+ $Acc.DoCmd.RunSQL("update DeepcleanEntryDoor set Title = 'Mrs'")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
Data appended, close Access ...
... process complete!
我还使用现有查询尝试了DoCmd.OpenQuery,但得到了相同的结果。
我在这里缺少什么?
由于
DB