Mapping columns in flat file import -
05-27-2006
, 12:16 PM
Hi all,
I'm new to SSIS and I've just started learning now. I'm trying to import a
comma delimited file in a database table creating a package
programmatically. I got everything working so far except the mappings
between the file columns and database fields in the table. I tried the
sample code that I found in the newsgroups but it doesn't work. I add the
connections, create the data pump task and add the components, set their
properties and initialize their meta data. When I try to map the columns I
don't know how to do it. Are the flat file coulmns parsed by the design
component or should I add them manually?
Here's my code to map the fields:
dataFlowTask.PathCollection.New().AttachPathAndPro pagateNotifications( _
flatfileSource.OutputCollection(0), oledbDestination.InputCollection(0))
' Iterate through the inputs of the component.
For Each input As IDTSInput90 In oledbDestination.InputCollection
' Get the virtual input column collection for the input.
Dim vInput As IDTSVirtualInput90 = input.GetVirtualInput()
' Iterate through the virtual column collection.
For Each vColumn As IDTSVirtualInputColumn90 In
vInput.VirtualInputColumnCollection
' Call the SetUsageType method of the design time destDesignTime of
the component.
Dim column As IDTSInputColumn90 =
destDesignTime.SetUsageType(input.ID, vInput, vColumn.LineageID,
DTSUsageType.UT_READONLY)
destDesignTime.MapInputColumn(input.ID, column.ID,
input.ExternalMetadataColumnCollection(vColumn.Nam e).ID)
Next
Next
But GetVirtualInput returns an empty collection. Is there something I'm
missing here?
I will really appreciate your help.
Thanks,
George |