Domino Code Fragment

Code Name*
Using LotusScript to Read from Non-Notes Databases
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.119.133.96
Description*
Using LotusScript to Read from Non-Notes Databases
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:

Exercise Title :

Where : Populate Agent

Solution :



(Options)

Option Public
Uselsx "*lsxodbc"
%INCLUDE "LSCONST.LSS"


(Initialise)

Sub Initialize

'-- Make ODBC Connection
Dim Con As New ODBCConnection
RetCode% = Con.ConnectTo("MRP System")

'-- Define ODBC Query
Dim Qry As New ODBCQuery

'-- Set Connection property of ODBCQuery Object
Set Qry.Connection = Con

'-- Set SQL property of ODBCQueryObject
Qry.SQL = "SELECT * FROM BIKEPART"

'-- Set Query property of ODBCResultSet
Dim res As New ODBCResultSet
Set Res.Query = Qry

'-- Execute the ODBC Query
Res.Execute

'-- Drill down to current database object
Dim Session As New NotesSession
Dim db As NotesDatabase
Set db = Session.currentdatabase

'-- Get First Row in ResultSet
RetCode% = Res.FirstRow

'-- Iterate through result set creating a new document for each row
Do While RetCode% = True

'-- Create new notes document object
Dim Doc As New NotesDocument(db)

'-- Set form item

doc.form = "Bikepart"

'-- Populate document object with values from row
doc.recid = Cstr( Res.GetValue("RECID") )
doc.partno = Res.GetValue("PARTNO")
doc.vendor = Res.GetValue("VENDOR")
doc.type = Res.GetValue("TYPE")
doc.dimension = Res.GetValue("DIMENSION")
doc.cost = Res.GetValue("COST")

'-- Save document
Call doc.save (True, True)

'-- Get Next Row in ResultSet
RetCode% = Res.NextRow
Loop

RetCode% = Res.Close( DB_CLOSE )
RetCode% = Con.Disconnect

End Sub