You will need a driver for the connection and this is where it gets more
complicated. What version of DB2 are you connecting to? Is it running on
AIX? NT? OS390? AS400? Basically, you'll need to find the ODBC and/or
OLE DB (if it's available for the version of DB2 you're running) drivers for
the version and platform of DB2 you are running. Two good places to start
are IBM's Web site (specifically the sections about DB2) and the Micrsoft
Web site (specifically the section about data access at
http://www.microsoft.com/data/).
Depending on your version of DB and the platform it's on, you may need or
want to use a third-party vendor's drivers. We currently use Neon Systems'
ShadowDirect to create an ODBC connection to DB2 running on an OS/390
mainframe.
Code:
OLE DB Provider for DB2 (from Microsoft)
For TCP/IP connections
oConn.Open = "Provider=DB2OLEDB;" & _
"Network Transport Library=TCPIP;" & _
"Network Address=xxx.xxx.xxx.xxx;" & _
"Initial Catalog=MyCatalog;" & _
"Package Collection=MyPackageCollection;" & _
"Default Schema=MySchema;" & _
"User ID=MyUsername;" & _
"Password=MyPassword"
For APPC connections
oConn.Open = "Provider=DB2OLEDB;" & _
"APPC Local LU Alias=MyLocalLUAlias;" & _
"APPC Remote LU Alias=MyRemoteLUAlias;" & _
"Initial Catalog=MyCatalog;" & _
"Package Collection=MyPackageCollection;" & _
"Default Schema=MySchema;" & _
"User ID=MyUsername;" & _
"Password=MyPassword"