使用 PowerShell 连接到 DB2 [英] Connecting to DB2 using PowerShell
问题描述
我正在尝试连接到 DB2 数据库并执行一些查询.几天前我让它工作了,但现在它给出了一些非常奇怪的错误,我不知道为什么.
I'm trying to connect to a DB2 database and execute some queries. I had it working a few days ago, but now it's giving some really strange errors and I can't figure out why.
PowerShell 连接代码
The PowerShell connection code
$connection = New-Object System.Data.OleDb.OleDbConnection("Provider=IBMDADB2;Database=X;HostName=X;Protocol=TCPIP;Port=X;Uid=X;Pwd=X;CurrentSchema=X");
$ds = New-Object "System.Data.DataSet"
$da = New-Object System.Data.OleDb.OleDbDataAdapter($QuerySQL, $connection)
$da.Fill($ds)
$ds.Tables[0].Rows |
select * -ExcludeProperty RowError, RowState, HasErrors, Name, Table, ItemArray |
Export-Csv "c:Scripts
esults.csv" -encoding "unicode" -notype
我看到的错误:
使用1"参数调用Fill"的异常:没有可用的错误消息,结果代码:E_UNEXPECTED(0x8000FFFF)."
Exception calling "Fill" with "1" argument(s): "No error message available, result code: E_UNEXPECTED(0x8000FFFF)."
有人知道为什么会出现这种情况吗?
Anybody got any ideas why this is cropping up?
我还有其他使用 Fill()
的脚本以完全相同的方式使用不会产生错误,所以这真的让我很困惑!
I've got other scripts that use Fill()
in the exact same way an don't produce errors, so this is really baffling me!
推荐答案
好的,我想通了.
您需要以管理员身份运行 powershell 才能使用 DB2 驱动程序.为什么会这样,我不知道,但我就是这样解决的!
You need to run powershell as admin to use the DB2 driver. Why this is, I don't know, but that's how I fixed it!
这篇关于使用 PowerShell 连接到 DB2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!