正如主题所说,我在Access中直接对MDB进行了查询,我有一个PowerShell脚本可以使用不同的查询,但是此查询不返回任何数据。想法?
这有效......
$path = "C:\temp\Config.mdb"
$adOpenStatic = 3
$adLockOptimistic = 3
$cn = new-object -comobject ADODB.Connection
$rs = new-object -comobject ADODB.Recordset
$cn.Open("Provider = Microsoft.Jet.OLEDB.4.0;Data Source = $path")
$Ports = $rs.open("Select * from Options where OptionName='Eng.SerialPortMgr.PrinterPort1'",$cn,$adOpenStatic,$adLockOptimistic)
$rs.MoveFirst()
do {
$rs.Fields.Item("OptionName").value + " = " + $rs.Fields.Item("OptionData").value;
$rs.MoveNext()}
until($rs.EOF -eq $True)
$rs.Close()
$cn.Close()
$Ports
这不,我不明白为什么。唯一的区别是查询和此脚本中的查询可用于Access ...
$path = "C:\temp\Config.mdb"
$adOpenStatic = 3
$adLockOptimistic = 3
$cn = new-object -comobject ADODB.Connection
$rs = new-object -comobject ADODB.Recordset
$cn.Open("Provider = Microsoft.Jet.OLEDB.4.0;Data Source = $path")
$Ports = $rs.open("SELECT Options.OptionName, Options.OptionData FROM Options WHERE OptionName LIKE 'Eng.SerialPortMgr.PrinterPort*'",$cn,$adOpenStatic,$adLockOptimistic)
$rs.MoveFirst()
do {
$rs.Fields.Item("OptionName").value + " = " + $rs.Fields.Item("OptionData").value;
$rs.MoveNext()}
until($rs.EOF -eq $True)
$rs.Close()
$cn.Close()
$Ports
答案 0 :(得分:0)
这有效......
$path = "C:\temp\Config.mdb"
$adOpenStatic = 3
$adLockOptimistic = 3
$cn = new-object -comobject ADODB.Connection
$rs = new-object -comobject ADODB.Recordset
$cn.Open("Provider = Microsoft.Jet.OLEDB.4.0;Data Source = $path")
$SawConfigPorts = $rs.open("SELECT Options.OptionName, Options.OptionData FROM Options WHERE OptionName LIKE 'Eng.SerialPortMgr.PrinterPort%'",$cn,$adOpenStatic,$adLockOptimistic)
$rs.MoveFirst()
do {
$rs.Fields.Item("OptionName").value + " = " + $rs.Fields.Item("OptionData").value;
$rs.MoveNext() }
until($rs.EOF -eq $True)
$rs.Close()
$cn.Close()
$SawConfigPorts