The AddLookup method adds a parameterized query to the Lookups collection.
object.AddLookup Name, Query, ConnectionID, [MaxCacheRows]
Part | Description |
---|---|
object | Expression that evaluates to a Lookups collection |
Name | String that is the lookup query name |
Query | String that is the SQL query |
ConnectionID | Long that is the connection ID |
MaxCacheRows | Long that is the maximum number of rows to cache for reuse |
Typically, a Lookup object is referenced in a Microsoft® ActiveX® script. The Query is executed against the data source specified by the ConnectionID. The first row of the returned rowset is used. MaxCacheRows specifies the number of rows cached locally so that subsequent lookups that target that row do not need to reissue the query against the data source.
The AddLookup method does not return a reference to the Lookup object it creates. You also can create the Lookup object with the New method, set its properties, and then add it to the collection with the Add method.
HRESULT AddLookup(BSTR Name,
BSTR Query,
long ConnectionID,
long MaxCacheRows);
This Microsoft Visual Basic® sample creates and adds a Lookup object to the collection:
objDataPump.Lookups.AddLookup "ExpandState", _
"SELECT StateName FROM StateInfo WHERE POCode = ?", _
2, 50