Automatically Select Input Columns in a Custom Data Flow Component

The following code snippet can be used in a custom data flow component to automatically select all input columns when you attach a path.

This is the equivalent to clicking the Select All box in the Advanced Editor.

image 

7 Responses to “Automatically Select Input Columns in a Custom Data Flow Component”

  1. Thank you for providing this code sample. I have been wanting to learn more about how to design custom components and examples like this one are a a big help.

  2. bidyut says:

    Matt,

    Like Jesus you can walk on water. Hats off to you. Your example to automatically attach the output path helped a lot! I have been scavenging all over the net, finally I found something to be taken seriously.

    I have created a custom destination component following the example at http://msdn.microsoft.com/en-us/library/ms135899….. But the component does not allow data to be inserted in a table. I would like to dynamically pick up the columns from the source and dynamically map it to the destination adapter and load the data.

    Cheers!
    Bids

  3. bidyut says:

    Hi Matt,

    I got a problem now. The method 'OnInputPathAttached' (in your example) automatically selects the 'input columns', but If I add one more column to the source adapter, this new column is not automatically selected in the destination adapter. How to automatically add the newly added column in the source adapter to the ' input column of the destination adapter'? Please help it is urgent.

    • Matt Masson says:

      Unfortunately, you won't be able to do this in the Data Flow. Columns (along with all of the other metadata) must be defined at design time. Your component cannot automatically remap new columns at runtime without user interaction through the designer.

      • Linda Lawton says:

        Im working on this issue as well. If the user adds a new column you can find them in VirtualInputColumnCollection in validate but like you said InputColumnCollection appears to remain the same. I haven't been able to decide how best to add the new InputColumn. IMO the system should add the new column. OnDeletingInputColumn doesn't appear to fire if you remove a column directly you have to call ComponentMetaData.RemoveInvalidInputColumns(); at the beginning of validate to have any columns they may have deleted removed.

        btw thanks for this with your code I was able to get started.

  4. bidyut says:

    Thanks for your response. Can't I select (check) the newly columns through C# code?

  5. bidyut says:

    I found a way to automatically map the source columns (from the source adapter) to the destination adapter, given the column name is same. My 'custom source component' automatically adds new columns to the 'external available columns' and 'output columns'. The 'custom destination' adapter now automatically 'checks/selects' the newly added columns to the destination adapter. This makes the adapters quite powerful, agile. As addition of new columns to the source and destination does not require development, testing and deployment effort of the SSIS packages the EL processes becomes more agile.

Leave a Reply

You must be logged in to post a comment.