1

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.

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

The error I'm seeing:

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?

I've got other scripts that use Fill() in the exact same way an don't produce errors, so this is really baffling me!

2
  • I would guess that if your other scripts are using this same pattern to connect to the same DB2 instance, the problem may be with your SQL query. Can you add it to the question? Commented Aug 8, 2012 at 12:52
  • I've executed the query separately and it's works :/ Commented Aug 8, 2012 at 13:36

2 Answers 2

1

Ok, I've figured it out.

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!

Sign up to request clarification or add additional context in comments.

Comments

0

You need to add the user to the DB2Users or DB2Admns groups. The local Administrators group works, too, but for security reasons the other two groups are more appropriate. These groups are typically created by default on the server to which you install DB2. They are local groups.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.