Saturday, April 12, 2008

QTP DB2 connection using ODBC

Requirements: IBM DB2 ODBC Driver
Function DB2Connect ()
DB2ConnStr = "Provider=IBMDADB2.1; Database=HSAPSETS; Hostname=DB2Host; Schema=Schema;Protocol=TCPIP; Port=50004; Uid=Db2user; Pwd=Db2Pass"
Set DB2Cn = CreateObject("ADODB.Connection") 'Create Object ADODB Connection
With DB2Cn
.CursorLocation = 3 : .ConnectionString = DB2ConnStr : .Open
End with
End Function

5 comments:

Anonymous said...

Hey sunil,

thank u the code was relly helpful..

Sunil Patel said...

Thank for visiting my blog.
-Sunil

Anonymous said...

Hi Sunil,

Just what i was looking for, thanks for the code snippet !

swetha said...

Hi Sunil,

When i try executing ur code, i get error "Provider cannot be found, It may not be properly installed"

I have also installed ODBC driver.

Please let me know the workaround

Unknown said...

Hi Sunil,

Thanks for your code!

Actually, I really know the answer for my question below. But still wanted to get confirmed from an expert on this.

Can we establish DB2 connection without IBM DB2 ODBC DRIVER? Is it really possible?

I know it's not possible, however asked to get confirmation. Thanks!

~~ Gopi