Share via


DBStorage.LookupData Method (PIA)

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

[Visual Basic .NET]

Imports Microsoft.CommerceServer.Interop.Orders
…
Public Function LookupData(vtReserved As Object,
 ByRefpvtKeys As Object,
 ByRefpvtValues As Object) As Object

[C#]

using Microsoft.CommerceServer.Interop.Orders;
…
public object LookupData(objectvtReserved,
 ref objectpvtKeys,
 ref objectpvtValues);

Parameters

[Visual Basic .NET]

  • vtReserved
    An Object reserved for future use. The LookupData method ignores any value stored in this parameter.
  • pvtKeys
    An Object that identifies the columns in which to search for the data. This Object can be either a SimpleList object or a System.Array.
  • pvtValues
    An Object that identifies the values for which to search. This parameter can be either a SimpleList object or a System.Array.

[C#]

  • vtReserved
    An object reserved for future use. The LookupData method ignores any value stored in this parameter.
  • pvtKeys
    A reference to an object that identifies the columns in which to search for the data. This object can be either a SimpleList object or a System.Array.
  • pvtValues
    A reference to an object that identifies the values for which to search. This parameter can be either a SimpleList object or a System.Array.

Return Values

[Visual Basic .NET] If this method completes successfully, it returns an Object that contains the result of the lookup; this Object references a Dictionary object that contains the row data.

[C#] This method returns the result of the lookup: a Dictionary object that contains the row data. If the method call is unsuccessful, this parameter evaluates to null.

Exceptions

This method may throw one of many mapped exceptions or an exception of type COMException. See Standard COM Errors for additional details.

Remarks

[Visual Basic .NET]

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.

[C#]

The pvtRet parameter points to valid data only if the method returns successfully.

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.

[Visual Basic .NET]

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

Dim keys(1) As String
Dim values(1) As Object
keys(0) = "shopper_id"
keys(1) = "shopper_name"
values(0) = shopper_id
values(1) = Page.Request("shopper_name", Null, 1, 60)
exists = OrderFormStorage.LookupData(DBNull.Value, keys, values)
If IsNull(exists) Then
' This shopper id and name does not exist in the specified columns

Requirements

Namespace: Microsoft.CommerceServer.Interop.Orders

Platforms: Windows 2000, Windows Server 2003

Assembly: commercelib (in commercelib.dll)

See Also

DBStorage Class

DBStorage.InitStorage

DBStorage.GetData

DBStorage.LookupMultipleData

Copyright © 2005 Microsoft Corporation.
All rights reserved.