Examples: NumParameters method
This example shows two actions (the Click subs) that set and get parameters for the SQL query in the Postopen sub. Although the query in the Postopen sub contains exactly two parameters, these actions work for a variable number of parameters. The actions use NumParameters for loop control in processing the 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