• twitter

  • Advertisements

How to actually get the AS400 oledb connection with .net

Get yourself a copy of DB2OLEDBV4_x86.msi (or a 64 bit version DB2OLEDBV4_x64.msi)

Get yourself the Microsoft Visual C++ Redistributable Package

Or get the 64bit version as well

Install yourself a version of SQL Server 2008 or later version

And… get yourself a copy of .net 4.0 yeesh

OK….. after fighting that for way too long time to try the IBM odbc driver.

It is downloaded from here

Have fun getting an account and getting the Driver for ODBC and CLI (64-bit) downloaded

Then unzip it and run

cd <uncompressed driver folder>/bin
db2cli install -setup

Now I have a new data source called IBM DB2 ODBC DRIVER

Scratch that, I finally got the stupid OLEDB driver to work. The key is to use verbatim string literal (which doesn’t exist in So instead use <![CDATA[
SELECT * FROM [TABLE] where RTTICK = ‘852’

From this post

Dim connectionString As String = “Provider=DB2OLEDB;User ID=;Password=;Initial Catalog=;Network Transport Library=TCPIP;Host CCSID=1208;PC Code Page=1252;Network Address=;Network Port=446;Package Collection=;Default Schema=;Units of Work=RUW;Default Qualifier=;DBMS Platform=DB2/AS400;Use Early Metadata=False;Defer Prepare=False;DateTime As Char=False;Rowset Cache Size=0;Binary CodePage=0;Datetime As Date=False;AutoCommit=True;Database Name=;Authentication=Server;Decimal As Numeric=False;Derive Parameters=True;LoadBalancing=False;Persist Security Info=True;Cache Authentication=False;Connection Pooling=False;”

Using connection = New OleDbConnection(connectionString)

Dim command = New OleDbCommand()
command.CommandText = <![CDATA[
SELECT * FROM [TABLE] where RTTICK = ‘852’

command.Connection = connection
Dim reader = command.ExecuteReader()
If reader.HasRows Then
While reader.Read()
End While
End If
End Using


Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: