Hello,I have been facing a severe problem while trying to connect a remote DB2 Database from Domino database.
I intend to use LCConnection, LCField, LCFieldList etc. to send/retrieve/modify the data from a Domino Database to DB2 database.
I have installed DB2 cLient on the machine from which I intend to connect remote DB2 database with the required DB2 database cataloged from the DB2 Client.
I have been trying to create a connection document on a server with DECS service running to the remote DB2 server and I succeded. Then, using Lotus Script I tried to connect the DB2 Server again from the machine on which both Domino server & DB2 client are installed through an agent. I again succeded to connect.
The problem arises when I try to select the rows from the database table with select query. It returns Nothing. Following is the code that I have used to connect:
Sub Click(Source As Button)
Dim doc As NotesDocument
Dim conn As New LCConnection("db2")
Dim Lcfieldlst As New LCFieldList
Dim Lcfield As LCField
Dim LCFempid,LCFempdesig,LCFempdept As LCField
conn.database="<database_Name>"
conn.Password="<password>"
conn.UserID="<user_Name>"
On Error Goto Trap
conn.Connect
Msgbox "DB2 Connected Successfully"
If(conn.Execute("Select * from emp",Lcfieldlst)=0) Then
Msgbox "No Records Found"
Else
Set Lcfield = Lcfieldlst.Lookup("ENAME")
Set LCFempid = Lcfieldlst.Lookup("EMPNO")
Set LCFempdesig = Lcfieldlst.Lookup("JOB")
Set LCFempdept = Lcfieldlst.Lookup("DEPTNO")
End If
conn.Disconnect
Msgbox "Disconnected From DB2"
Exit Sub
Trap:
Msgbox "Connection To DB2 Database Failed"
End Sub
But when I Debugged the script I found an amazing thing.
I found that conn.Connect gave me the handle to the database with the property Connected = true.
But when the line conn.Execute()… fired the return type was LCCOUNT_UNKNOWN where it should have returned the number of records in the table.
Its really puzzling me as to how it could happen that even after connecting the database it is unable to fetch data while there is data in the table.
Similar Lotus script Code worked with Oracle when Oracle was installed in my local machine but failing with remote DB2.
Please Note: For connection I have been using Administrator Login ID for the DB2 database.
Could Someone provide some suggestions/solutions to this problem. That would be of great help.
Thanks a lot.