LOTUS CONNECTORS


Examples: Connection property
The following example of form scripts sets up the necessary query connections in the Postopen script. The Connection property of ODBCQuery must specify an ODBCConnection object. The Query property of ODBCResultSet must specify the ODBCQuery object.

Uselsx "*LSXODBC"

Dim con As ODBCConnection
Dim qry As ODBCQuery
Dim result As ODBCResultSet

Sub Postopen(Source As Notesuidocument)
 Set con = New ODBCConnection
 Set qry = New ODBCQuery
 Set result = New ODBCResultSet
 Set qry.Connection = con
 Set result.Query = qry
End Sub

Sub Click(Source As Button)
 Dim firstName As String
 Dim lastName As String
 Dim msg As String
 con.ConnectTo("ATDB")
 qry.SQL = "SELECT * FROM STUDENTS"
 result.Execute
 If result.IsResultSetAvailable Then
   msg = "Student names:" & Chr(10)
   Do
     result.NextRow
     firstName = result.GetValue("FIRSTNAME",  _
     firstName)
     lastName = result.GetValue("LASTNAME", _
     lastName)
     msg = msg & Chr(10) & firstName & " " & _
     lastName
   Loop Until result.IsEndOfData
   Messagebox msg,, "Student names"
   result.Close(DB_CLOSE)
 Else
   Messagebox "Cannot get result set"
   Exit Sub
 End If
 con.Disconnect
End Sub

See Also