public void AddPathsAndConnectColumns(Hashtable colPairs) { IDTSOutput100 srcOutput = srcComp.OutputCollection[0]; IDTSOutputColumnCollection100 srcOutputCols = srcOutput.OutputColumnCollection; IDTSInput100 destInput = destComp.InputCollection[0]; IDTSInputColumnCollection100 destInputCols = destInput.InputColumnCollection; IDTSExternalMetadataColumnCollection100 destExtCols = destInput.ExternalMetadataColumnCollection; Hashtable destColtable = new Hashtable(destExtCols.Count); foreach (IDTSExternalMetadataColumn100 extCol in destExtCols) { destColtable.Add(extCol.Name, extCol); } bool useMatch = (colPairs != null && colPairs.Count > 0); // colConvertTable stores a pair of columns which need a type conversion // colConnectTable stores a pair of columns which dont need a type conversion and can be connected directly. Hashtable colConvertTable = new Hashtable(srcOutputCols.Count); Hashtable colConnectTable = new Hashtable(srcOutputCols.Count); foreach (IDTSOutputColumn100 outputCol in srcOutputCols) { // Get the column name to look for in the destination. // Match column by name if match table is not used. String colNameToLookfor = String.Empty; if (useMatch) { colNameToLookfor = (String)colPairs[outputCol.Name]; } else { colNameToLookfor = outputCol.Name; } IDTSExternalMetadataColumn100 extCol = (String.IsNullOrEmpty(colNameToLookfor)) ? null : (IDTSExternalMetadataColumn100)destColtable[colNameToLookfor]; // Does the destination column exist? if (extCol != null) { // Found destination column, but is data type conversion needed? if (NeedConvert(outputCol.DataType, extCol.DataType)) { colConvertTable.Add(outputCol.ID, extCol); } else { colConnectTable.Add(outputCol.ID, extCol); } } } if (colConvertTable.Count > 0) { // add convert component AddConvertComponent(colConvertTable, colConnectTable); pipeline.PathCollection.New().AttachPathAndPropagateNotifications(convertComp.OutputCollection[0], destInput); } else { // Convert transform not needed. Connect src and destination directly. pipeline.PathCollection.New().AttachPathAndPropagateNotifications(srcOutput, destInput); } IDTSVirtualInput100 destVirInput = destInput.GetVirtualInput(); foreach (object key in colConnectTable.Keys) { int colID = (int)key; IDTSExternalMetadataColumn100 extCol = (IDTSExternalMetadataColumn100)colConnectTable[key]; // Create an input column from an output col of previous component. destVirInput.SetUsageType(colID, DTSUsageType.UT_READONLY); IDTSInputColumn100 inputCol = destInputCols.GetInputColumnByLineageID(colID); if (inputCol != null) { // map the input column with an external metadata column destDesignTimeComp.MapInputColumn(destInput.ID, inputCol.ID, extCol.ID); } } }