Best Way to Run Repeated Parametized Queries in ADO

Best Way to Run Repeated Parametized Queries in ADO

Post by Daniel D. Johnso » Wed, 06 Dec 2000 04:00:00



Every time the user of our app moves from one record to the next, our app
fills the list of a Combo box with a list of values from the field of a
table.  Here is an example:

Dim rsEmployees as New ADODB.Recordset
Dim i as Integer

rsEmployees.Open "SELECT sFullName FROM tblEmployees WHERE sSupervisor=?",
conn, adOpenKeyset, adLockOptimistic, adCmdText

For i = 1 to rsEmployees.RecordCount
    Combo1.AddItem rsEmployees.Fields(0)
    rsEmployees.MoveNext
Next

Since this needs to be done quite frequently, and since the list of values
might get to be pretty extensive, we need to make sure the code processes
the query as fast as possible.  What is the best way in ADO to do this?  If
opening the recordset using a "prepared" Command object and a related
Parameter object is the best way--how do you do it?  It's easy enough to set
up a Command object then create the recordset using the Command Object--but
how do you set up the Parameter object so that it is changed constantly???

Thanks for any advice in advance.

Dan Johnson