ContentListFactory.ConstructFromRecordset
Use this method to initialize a new ContentListFactory object, and create and initialize a new ContentListSchema object, from an ADO Recordset object.
Definition
Sub ConstructFromRecordset(Recordset As _Recordset,Skip As Variant,Add As ContentListSchema)
Parameters
Recordset
A reference to an ADO Recordset object from which the ContentList object will be constructed.
Skip
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
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 Values
None.
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 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.
Column types are mapped from the Recordset object according to the following table.
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 |
Note
- *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