does anyone has a sample lotuscript code that that connects to a DB2 database(AS/400), and get a certain field value on the database?
thanks in advance
does anyone has a sample lotuscript code that that connects to a DB2 database(AS/400), and get a certain field value on the database?
thanks in advance
Subject: AS/400 Connection
Maybe you can use this code of mine …
Option Declare
Uselsx “*LSXODBC”
'DECLARATIONS
Const ODBCUser = “USERNAME”
Const ODBCPassword = “PASSWORD”
Dim qry As odbcquery
Dim res As odbcresultset
Dim s As NotesSession
Dim db As NotesDatabase
Dim v As NotesView
Dim d As NotesDocument
Dim con As odbcconnection
Sub Initialize
Dim str_error As String
Dim str_message As String
Set s = New notessession
Set db = s.CurrentDatabase
Set con = New odbcconnection
Dim ODBCDriver As String
If s.IsOnServer Then
ODBCDriver = "s44k6113"
Else
ODBCDriver = "QDSN_DRYAS400" End If
If con.connectto(ODBCDriver, ODBCUser, ODBCPassword) Then
'HER KALDES IMPORT PROCEDUREN
Call SynkroniserPersonData
con.Disconnect
Else
str_error = con.geterror
str_message = con.geterrormessage(str_error)
Print "Fejl: " + str_message
End If
End Sub
Sub SynkroniserPersonData
Dim countCreated As Integer
Dim countUpdated As Integer
Dim v As NotesView
Dim d As NotesDocument
Dim i As Integer
Set v = db.GetView("lookupK")
Set qry = New odbcquery
Set res = New ODBCResultSet
Set qry.connection = con
qry.sql = |SELECT A.MHEMNM, A.MHEMNO, A.MAÆAN1, A.MAÆFD1, A.MHÆMA1, A.MHÆMA2, A.MHÆPNR, A.MHÆBYN, A.MHÆCPR|
qry.SQL = qry.SQL + | FROM S44K6113.RY11MVX01.HR01FIL A|
qry.SQL = qry.SQL + | WHERE A.MAÆFD1 = 0|
Set res.query = qry
If Not res.execute Then
Print res.getextendederrormessage,, res.geterrormessage
Else
Call res.LastRow 'For at kende res.NumRows
For i = 1 To res.NumRows
res.CurrentRow = i
Call v.Refresh
Set d = v.GetDocumentByKey(Trim(res.GetValue(2)))
If d Is Nothing Then
Set d = db.CreateDocument
d.Form = "PersonData"
d.teMedarbNr = res.GetValue(2)
countCreated = countCreated + 1
Else
countUpdated = countUpdated + 1
End If
d.teNavn = res.GetValue(1)
d.teAdresse = res.GetValue(5)
d.teAdresse2 = res.GetValue(6)
d.nuPostNr = res.GetValue(7)
d.teBy = res.GetValue(8)
d.teKode = Right(Cstr(res.GetValue(9)), 4)
d.teKundeNr = Trim(d.teMedarbNr(0))
Call d.ComputeWithForm(True, False)
Call d.Save(True, False)
Next
res.Close(DB_CLOSE)
End If
End Sub
Subject: Re: AS/400 Connection
I use odbc from client express to connect to as400. but the problem is, the agent is run on the server (w2k)… and when the server restart i have to login to the server first becauase the client access will ask for user name and password. without that the agent will never able to connect to as400.
is there anyway to overcome this? I’m thinking to use java agent with jtopen class… but… that another question.