Examples: GetParameter method

This example shows a form action (the second Click sub) that gets the parameters for the SQL query in the Postopen sub. Although the query in the Postopen sub contains exactly two parameters, the action works for a variable number of parameters.

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
  con.ConnectTo("ATDB")
  qry.SQL = "SELECT * FROM STUDENTS WHERE " & _
  "LASTNAME = ?lastName? AND FIRSTNAME = ?firstName?"
End Sub

Sub Click(Source As Button)
  Dim inputParameter As String
  For i = 1 To result.NumParameters
    inputParameter = Inputbox$(result.GetParameterName(i), _
    "Parameter " & i)
    Call result.SetParameter _
    (i, "'" & inputParameter & "'")
  Next
End Sub

Sub Click(Source As Button)
  Dim msg As String
  msg = "Parameter name = parameter value" & Chr(10)
  For i = 1 To result.NumParameters
    msg = msg & Chr(10) & result.GetParameterName(i) _
    & " = " & result.GetParameter(i)
  Next
  Messagebox msg,, "Parameters"
End Sub

Sub Queryclose(Source As Notesuidocument, Continue As Variant)
  result.Close(DB_CLOSE)
  con.Disconnect
End Sub