I'm trying to connect to my DB2 database server using the core ODBC functions SQLConnect() and SQLDriverConnect.

I can connect fine from within the Microsoft ODBC Administrator but not when using these functions.

The message I get back is

08001 IBMCLI Driver CLI0199E Invalid connection string attribute. SQLSTATE=08001 (-99999)

I am using the following code:

connectionString = "DSN=" & serverDSN & ";UID=" & user & ";PWD=" & password & ";"
iReturn = SQLDriverConnect(hDBC, 0, connectionString, Len(connectionString), strOut, Len(strOut), Cbout, SQL_DRIVER_COMPLETE)

or just

iReturn = SQLConnect(hDBC, serverDSN, SQL_NTS, user, SQL_NTS, password, SQL_NTS)

I can connect if I don't use an ODBC DSN with the following connection string:

connectionString = "Driver={" & odbcDriver & "};Database=" & dbAlias & ";Hostname=" & serverName & ";Port=" & port & ";Protocol=TCPIP;Uid=" & user & ";Pwd=" & password & ";"

However I would prefer to use the DSN rather that store all these additional data

Any ideas?

Thanks in advance,