Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

From Excel to DB2

Status
Not open for further replies.

smajeti

IS-IT--Management
Sep 23, 2005
2
US
Hello

I am trying to connect to DB2 Z/Os from Excel VBA and was successfull in connecting until my Hard Drive was replaced. Now when I try to connect it says

Error: Method 'Open' of object '_Connection' failed.

I tried the same code from my friends PC and it works fine there.

In my references I have the following checked
Visual Basic For Applications
Microsoft Excel 10.0 Object Library
Msft ActiveX Data Objects 2.7 Library
OLE Automation
Msft ActiveX Data Objects (Multi-dimensional) 2.7 Library

and here is my code

Dim ObjCnn As New Connection
ObjCnn.ConnectionString = "DSN=DB2DSNS;User ID=" & userid & ";PWD=" & pswd & ";"
ObjCnn.ConnectionTimeout = 600
ObjCnn.CursorLocation = adUseClient
ObjCnn.Open


I tried connecting to the DSN directly from ODBC and it works perfectly fine.

Any help to solve the problem is appreciated.
 


Hi,

Try,
Code:
sConn = "driver={IBM DB2 ODBC DRIVER};Database=myDbName;hostname=myServerName;port=myPortNum;protocol=TCPIP; uid=myUserName; pwd=myPwd"


Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top