使用PowerShell连接到DB2 [英] Connecting to DB2 using PowerShell

查看:164
本文介绍了使用PowerShell连接到DB2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试连接到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\results.csv" -encoding "unicode" -notype

我看到的错误:


使用 1参数调用填充的异常:否错误消息可用,结果代码: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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆