Category Archives: DB2

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.