Option Public
Option Declare
Uselsx "*lsxlc"
Sub Initialize
On Error Goto processError
Dim LCses As New LCSession
Dim conName As String, conList As String
Call LCses.ListConnector(LCLIST_FIRST, conName)
conList = conName
While LCses.ListConnector(LCLIST_NEXT, conName)
conList = conList + ", " + conName
Wend
Print "Available connectors are: " & conList
Dim con As New LCConnection ("odbc2")
Dim fieldList As New LCFieldList
Dim tableName As String
Dim sql As String
Dim count As Integer
tableName = "MyTable"
con.Server = "SomeSystemDSN"
con.Metadata = tableName
con.Userid = "MyUserName"
con.Password = "MyPassword"
con.Connect
sql = "SELECT * from " & tableName
Call con.Execute(sql, fieldList)
If (fieldList.FieldCount < 1) Then
Print "Sorry, no results"
Else
Dim fields List As LCField
Dim stream As LCStream
Dim i As Integer
For i = 1 To fieldList.FieldCount
Set fields(fieldList.GetName(i)) = fieldList.GetField(i)
Next
Print "The columns values that were returned were: "
Do While (con.Fetch(fieldList) > 0)
count = count + 1
Print " "
Print "ROW #" & count
Forall field In fields
If (field.Datatype < 7) Then
Print Listtag(field) & " = " & field.Value(0)
Else
Set stream = field.GetStream(1, LCSTREAMFMT_NATIVE)
Print Listtag(field) & " (Datatype: " & field.Datatype & ") = " & stream.Text
End If
End Forall
Loop
End If
con.Disconnect
Exit Sub
processError:
Dim errMsg As String
If (LCses.Status <> LCSUCCESS) Then
errMsg = "(LEI Error) " & LCses.GetStatusText
LCses.ClearStatus
Else
errMsg = Error$
End If
Print "Error on line " & Erl & ": " & errMsg
If con.IsConnected Then
con.Disconnect
End If
Exit Sub
End Sub
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.