DBStorage.LookupData
Use this method to retrieve a single row from the data source based upon column names and values that you specify. If the data is found, this method creates and returns an OrderForm or Dictionary object (depending on the vtProgID parameter passed to the InitStorage method) containing the requested data.
Definition
Function LookupData(vtReserved As Variant,pvtKeys As Variant,pvtValues As Variant) As Variant
Parameters
vtReserved
A Variant reserved for future use. The LookupData method ignores any value stored in this parameter.
pvtKeys
A Variant that identifies the columns in which to search for the data. This Variant can be either a SimpleList object or an Array.
pvtValues
A Variant that identifies the values for which to search. This parameter can be either a SimpleList object or an Array.
Return Values
If this method completes successfully, it returns a Variant that contains the result of the lookup; this Variant references a Dictionary object that contains the row data.
Error Values
This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to standard COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.
Remarks
The pvtKeys and pvtValues parameters are arrays that you pass to the LookupData method share in an index-to-index relationship. This means that they must contain an identical number of members and that the value stored in the pvtValues (N) parameter will be searched for in the column specified by the pvtKeys (N) parameter.
If the arrays contain more than one element, the LookupData method searches for a row in which all of the column/value pairs match.
Because the LookupData method returns only a single row of data, specifying column and value information that would result in the retrieval of more than one row results in an error.
For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.
Example
' OrderFormStorage is an initialized DBStorage object instance.
' In the following example, the LookupData method searches
' for a row in which both the shopper_id column contains the
' value returned by the shopper_id variable and the shopper_name
' column contains the customer name returned by the Page.Request method:
' Attempt to determine if this shopper is already registered.
shopper_id = Page.GetShopperID
On Error Resume Next
Dim keys(1)
Dim values(1)
keys(0) = "shopper_id"
keys(1) = "shopper_name"
values(0) = shopper_id
values(1) = Page.Request("shopper_name", Null, 1, 60)
exists=NULL
set exists = OrderFormStorage.LookupData(Null, keys, values)
If IsNull(exists) Then
' This shopper id and name does not exist in the specified columns