DB2 ODBC connection crashes with an Access Violation in DB2APP64.DLL

Im trying to work with DB2 (you’ll see a few more posts in regards to this) and I installed the ODBC driver on to my Win7 box and tried a simple connection/query with powershell, something like this.

$connstr = "DRIVER={IBM DB2 DRIVER for ODBC - C:/DB2ODBC};Database=myDB;Hostname=myServer;Port=1234;Protocol=TCPIP;Uid=user;Pwd=password;"
$conn = New-Object data.odbc.odbcconnection $connstr

$cmd = new-object data.odbc.odbccommand
$cmd.connection = $conn
$cmd.commandtext = "select * from myTable"

Normally this would be fine, but in the case of DB2, it crashes powershell stating there was an Access Violation with DB2APP64.DLL.

After a bit of screwing around, what I found was that this happens when you try to access a 32bit database (yeah, I have a 32bit DB2 system) from a 64 bit system.

Installing the 32 bit odbc driver and using 32bit powershell resolves this. Not how i’d like it to go, but, its all I could come up with.


About jrich

I am the Solutions Architect for Apex Learning in Seattle WA. I've been working with computers since I was 13. Started programming when I was 14. Had my first IT job as tech support at an ISP at the age of 15 and became a network admin at the age of 17. Since then I've worked at a variety of small to mid size companies supporting, maintaining and developing all aspects of IT. Mostly working with Windows based networks but have recently been working with Solaris system as well. I created this blog mostly as a place for me to take my own notes, but also share things that I had a hard time finding the info for.

Posted on October 27, 2011, in DB2, WMF (Powershell/WinRM) and tagged , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: