The AddColumn method creates a Column object by name and ordinal position and adds it to the collection.
Columns.AddColumn Name,Ordinal
Part | Description |
---|---|
Columns | Expression that evaluates to a Columns collection |
Name | String that is the name of the column |
Ordinal | Long that is the ordinal position of the column |
The AddColumn method does not return a reference to the column object it creates. If you need to set Column properties other than Name and Ordinal, you can create the Column object with the New method, set the properties, and then add it to the collection with the Add method. Or, you can access the Column object from the collection after creating it with AddColumn.
HRESULT AddColumn(
BSTR Name,
long Ordinal);
This Microsoft® Visual Basic® sample accesses a Column object from the collection after creating it with AddColumn. The expression objTransform.SourceColumns evaluates to a Columns collection:
Dim objTransForm As DTS.Transformation2
Dim objColumn As DTS.Column
. . .
objTransForm.SourceColumns.AddColumn "LastName", 2
Set objColumn = objTransForm.SourceColumns( "LastName" )