powershell - Powershell创建microsoft access数据库错误
问题描述
我在 windows powershell 中运行以下代码:
Function Create-DataBase($Db){
$application = New-Object -ComObject Access.Application
$application.NewCurrentDataBase($Db,10)
$application.CloseCurrentDataBase()
$application.Quit()
} #End Create-DataBase
#$dbname = Read-Host -Prompt 'Input your database name'
# database file location
$Db = 'C:\new.mdb'
If(Test-Path $Db){
Write-Host 'DB already exists' -fore green
}else{
Create-DataBase $Db
}
但得到以下错误,
使用“5”参数调用“NewCurrentDatabase”的异常:“尝试创建数据库时发生错误。” 在 E:\Mahmood\test2.ps1:3 char:33 + $application.NewCurrentDataBase <<<< ($Db,10) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
使用“0”参数调用“CloseCurrentDatabase”的异常:“您输入的表达式引用了一个已关闭或不存在的对象。” 在 E:\Mahmood\test2.ps1:4 char:35 + $application.CloseCurrentDataBase <<<< () + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
任何人都知道出了什么问题。
解决方案
推荐阅读
- html - 如何在 reactjs 中制作仪表板页面
- api - VS Code onDidChange 方法不监听/记录更改
- api-platform.com - 带有 ApiPlatfom 和 Gedmo NestedTree 的 JSON 补丁
- javascript - 是否有可以获取 ID 列表字符串的 RegExp?
- wordpress - 根据颜色属性在主要内容之前显示内容
- .net - 在我的类文件中访问的会话不是我的会话
- node.js - 如何从 NodeJs 后端更新 mongoDB 中数组中的对象
- javascript - 显示简单 javascript 代码的语法错误
- python-3.x - 加载 .gif 并检索物理尺寸
- c - VScode无法识别布尔值?