다음을 통해 공유


IContentListFactory::ConstructFromRecordset Method

Use this method to initialize a new ContentListFactory object, and create and initialize a new ContentListSchema object, from an ADO Recordset object.

HRESULT IContentListFactory::ConstructFromRecordset(
  _Recordset* Recordset,
  VARIANT Skip,
  IContentListSchema* Add
);
Sub ConstructFromRecordset(
    Recordset As _Recordset,
    Skip As Variant,
    Add As ContentListSchema
)

Parameters

  • Recordset
    [C++]

    [in] A pointer to an ADO Recordset object from which the ContentList object will be constructed.

    [Visual Basic]

    A reference to an ADO Recordset object from which the ContentList object will be constructed.

  • Skip
    [C++]

    [in,optional] A VARIANT that is a SimpleList object. The SimpleList object contains the names of field(s) that exist in the Recordset object but that should not have a column in the new ContentList object.

    [Visual Basic]

    An optional Variant that is a SimpleList object. The SimpleList object contains the names of field(s) that exist in the Recordset object but that should not have a column in the new ContentList object.

  • Add
    [C++]

    [in,optional] A pointer to the IContentListSchema interface of a ContentListSchema object that contains information about additional columns or new flags for existing columns that should be accounted for when the new ContentList object is created. Refer to the Remarks section for additional information.

    [Visual Basic]

    An optional reference to a ContentListSchema object that contains information about additional columns or new flags for existing columns that should be accounted for when the new ContentList object is created. Refer to the Remarks section for additional information.

Return Value

[C++]

This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.

[Visual Basic]

None.

Error Values

[C++]

This method returns S_OK (0x00000000) to indicate success and standard COM HRESULT 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, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic]

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 Skip and Add parameters are both optional.

Columns defined in the ContentListSchema object that do not exist in the Recordset object are added to the new schema for the ContentListFactory object. Schema columns defined in both the ContentListSchema object and in the Recordset object get their flag settings from the former object, overriding the default flag settings otherwise applied. Supplemental columns may be either shared or private. Data for any supplemental, shared columns should be initialized using the SetData method. Data for any supplemental, private columns cannot be provided until a corresponding ContentList object is created.

The default value for dwFlags for columns created from the fields of the Recordset object is CLCOL_READONLY.

The ContentListFactory object attempts to access the RecordCount property of the RecordSet to determine how many rows of data for which space should be allocated. Not all types of RecordSets support this. If the RecordCount property cannot be determined, the ContentListFactory object will grow the factory in chunks of 100 rows. For this reason, it is most efficient to pass a RecordSet for which the RecordCount property is defined.

The following table shows the Column types that are mapped from the Recordset object.

ADO Type

ContentList Type

adSmallInt, adUnsignedSmallInt

CLCOL_I2

adInteger, adUnsignedInt, adError

CLCOL_I4

adSingle

CLCOL_I4

adDouble

CLCOL_R8

adDBDate, adDBTime, adDBTimeStamp

CLCOL_DATE

adChar, adVarChar, adLongVarChar, adWChar, adVarWChar, adLongVarWChar

CLCOL_STRING

adChapter*, adDispatch

CLCOL_DISPATCH

adChapter

CLCOL_UNKNOWN

adBoolean

CLCOL_BOOL

*One level hierarchical Recordset objects are supported. The child Recordset objects are created in the ContentList object as a SimpleList of Dictionary objects.

Example

'rsSource is an existing recordset.
'vSkip is a simple list of fields to ignore.
'vSchema is a ContentListSchema object.
myContentListFactory.ConstructFromRecordset rsSource, vSkip, vSchema

See Also

Other Resources

ContentListFactory Object