Component has not input columns and/or input columns have invalid id when creating package programmatically

I am developing an ETL tool which has to create SSIS packages dynamically (and later execute them without being edited in Data Tools). One of my proto type scenarios is a simple data flow from a flat file to a flat file - without anything in between.
However there is a problem with the columns of the flat file destination - it says it doesn't have any.
Saving the package to XML and opening the destination component in the advanced editor (tab "Input and Output Properties") really shows that are no input columns defined. One click on the tab "Column Mappings" however solves the
problem. The columns and the mapping are generated, the package can run.
I already tried to place "ReinitializeMetaData()" calls nearly anywhere in the code, for both components, unfortunately without success:
destinationComponentWrapper.AcquireConnections(null);
destinationComponentWrapper.ReinitializeMetaData();
destinationComponentWrapper.ReleaseConnections();
The actual error during validation is (When the line for column mapping in the code below is commented out):
"0xC020201B - The number of input columns for Flat File Destination.Inputs[Flat File Destination Inputs] cannot be zero"
I am also trying to insert a column mapping - this leads to a com error: 0xC020201B
In this case I am wondering why Data Tools tell me that there are no input columns yet I can iterate over them - they just don't have a valid ID (0x8000004B / -2147483573) which is then causing the 0xC020201B.
See also "PROBLEM HERE" marker in the code below.
How can I make the destination component recognize the columns programmatically, as when I click on the "Column Mappings" tab of the advanced editor of the component in Data Tools?
Here is the complete proto type code:
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dts = Microsoft.SqlServer.Dts;
namespace msdatapipe
class Program
static void Main(string[] args)
Dts.Runtime.Application application = new Dts.Runtime.Application();
Dts.Runtime.Package package = new Dts.Runtime.Package();
package.Name = "Data Commander DTS Package";
// ADD PIPELINE TASK
Dts.Runtime.Executable pipelineExecutable = package.Executables.Add("STOCK:PipelineTask");
Dts.Runtime.TaskHost pipelineTaskHost = (Dts.Runtime.TaskHost)pipelineExecutable;
pipelineTaskHost.Name = "Data Commander Pipeline Task";
Dts.Pipeline.Wrapper.MainPipe pipelineTask = (Dts.Pipeline.Wrapper.MainPipe) pipelineTaskHost.InnerObject;
// ADD SOURCE COMPONENT TO THE PIPELINE TASK
String sourceFilePath = "C:\\cmi\\tmp\\data.csv";
Dts.Runtime.ConnectionManager sourceConnectionManager = package.Connections.Add("FLATFILE");
sourceConnectionManager.ConnectionString = sourceFilePath;
sourceConnectionManager.Name = "Source Connection";
sourceConnectionManager.Description = "Source Connection Manager";
sourceConnectionManager.Properties["ColumnNamesInFirstDataRow"].SetValue(sourceConnectionManager, "True");
sourceConnectionManager.Properties["Format"].SetValue(sourceConnectionManager, "Delimited");
sourceConnectionManager.Properties["TextQualifier"].SetValue(sourceConnectionManager, "\"");
sourceConnectionManager.Properties["CodePage"].SetValue(sourceConnectionManager, "65001");
sourceConnectionManager.DelayValidation = false;
// START --- MANUALLY READ COLUMNS FROM TEXT FILE AND ADD TO SOURCE CONNECTION MANAGER COLUMNS
IDTSConnectionManagerFlatFile100 sourceConnectionInterface = sourceConnectionManager.InnerObject as IDTSConnectionManagerFlatFile100;
using (StreamReader reader = new StreamReader(sourceFilePath))
String firstSourceFileLine = reader.ReadLine();
String[] columnNames = firstSourceFileLine.Split(',');
for (int i = 0; i < columnNames.Length; ++i)
columnNames[i] = columnNames[i].Substring(1, columnNames[i].Length - 2);
IDTSConnectionManagerFlatFileColumns100 sourceColumns = sourceConnectionManager.Properties["Columns"].GetValue(sourceConnectionInterface) as IDTSConnectionManagerFlatFileColumns100;
IDTSConnectionManagerFlatFileColumn100 column = null;
foreach (String columnName in columnNames)
column = sourceColumns.Add();
column.DataType = DataType.DT_TEXT;
column.ColumnDelimiter = ",";
column.TextQualified = true;
(column as IDTSName100).Name = columnName;
Console.WriteLine(columnName);
column.ColumnDelimiter = "\r\n";
// END --- MANUALLY READ COLUMNS FROM TEXT FILE AND ADD TO SOURCE CONNECTION MANAGER COLUMNS
sourceConnectionInterface.RowDelimiter = "\r\n";
Dts.Pipeline.Wrapper.IDTSComponentMetaData100 sourceComponent = pipelineTask.ComponentMetaDataCollection.New();
sourceComponent.Name = "Flat File Source";
sourceComponent.ComponentClassID = "DTSAdapter.FlatFileSource";
sourceComponent.ValidateExternalMetadata = true;
CManagedComponentWrapper sourceComponentWrapper = sourceComponent.Instantiate();
sourceComponentWrapper.ProvideComponentProperties();
// LINK CONNECTION TO THE SOURCE COMPONENT
sourceComponent.RuntimeConnectionCollection[0].ConnectionManager = Dts.Runtime.DtsConvert.GetExtendedInterface(sourceConnectionManager);
sourceComponent.RuntimeConnectionCollection[0].ConnectionManagerID = sourceConnectionManager.ID;
// Connect to the data source, and then update the metadata for the source.
//sourceComponentWrapper.Validate();
//sourceComponentWrapper.ProvideComponentProperties();
sourceComponentWrapper.AcquireConnections(null);
sourceComponentWrapper.ReinitializeMetaData();
sourceComponentWrapper.ReleaseConnections();
// ADD DESTINATION CONNECTION MANAGER
Dts.Runtime.ConnectionManager destinationConnectionManager = package.Connections.Add("FLATFILE");
destinationConnectionManager.ConnectionString = "C:\\cmi\\tmp\\data_out.csv";
destinationConnectionManager.Name = "DatComConOut";
destinationConnectionManager.Description = "Data Commander Connection Manager";
destinationConnectionManager.DelayValidation = false;
destinationConnectionManager.Properties["Format"].SetValue(destinationConnectionManager, "Delimited");
destinationConnectionManager.Properties["TextQualifier"].SetValue(destinationConnectionManager, "\"");
destinationConnectionManager.Properties["CodePage"].SetValue(destinationConnectionManager, "65001");
// ADD DESTINATION COMPONENT
Dts.Pipeline.Wrapper.IDTSComponentMetaData100 destinationComponent = pipelineTask.ComponentMetaDataCollection.New();
destinationComponent.Name = "Flat File Destination";
destinationComponent.ComponentClassID = "DTSAdapter.FlatFileDestination";
destinationComponent.ValidateExternalMetadata = true;
CManagedComponentWrapper destinationComponentWrapper = destinationComponent.Instantiate();
destinationComponentWrapper.ProvideComponentProperties();
destinationComponent.RuntimeConnectionCollection[0].ConnectionManager = Dts.Runtime.DtsConvert.GetExtendedInterface(destinationConnectionManager);
destinationComponent.RuntimeConnectionCollection[0].ConnectionManagerID = destinationConnectionManager.ID;
// CREATE PATH
Dts.Pipeline.Wrapper.IDTSPath100 pipelinePath = pipelineTask.PathCollection.New();
pipelinePath.AttachPathAndPropagateNotifications(sourceComponent.OutputCollection[0], destinationComponent.InputCollection[0]);
// DESTION CONNECTION MANAGER COLUMNS
IDTSConnectionManagerFlatFile100 destinationConnectionInterface = destinationConnectionManager.InnerObject as IDTSConnectionManagerFlatFile100;
IDTSConnectionManagerFlatFileColumns100 destinationColumns = destinationConnectionManager.Properties["Columns"].GetValue(destinationConnectionManager) as IDTSConnectionManagerFlatFileColumns100;
// START --- MANUALLY READ COLUMNS FROM DESTINATION COMPONENT AND ADD THEM TO DESTIONATION CONNECTION MANAGER COLUMNS
foreach (IDTSInput100 input in destinationComponent.InputCollection)
IDTSVirtualInput100 virtualInput = input.GetVirtualInput();
IDTSConnectionManagerFlatFileColumn100 column = null;
foreach (IDTSVirtualInputColumn100 virtualInputColumn in virtualInput.VirtualInputColumnCollection)
column = destinationColumns.Add();
column.DataType = DataType.DT_TEXT;
column.ColumnDelimiter = ",";
column.TextQualified = true;
(column as IDTSName100).Name = virtualInputColumn.Name;
column.ColumnDelimiter = "\r\n";
// END --- MANUALLY READ COLUMNS FROM DESTINATION COMPONENT AND ADD THEM TO DESTIONATION CONNECTION MANAGER COLUMNS
// NEED TO CREATE NEW META DATA AFTER COLUMNS
destinationComponentWrapper.AcquireConnections(null);
destinationComponentWrapper.ReinitializeMetaData();
destinationComponentWrapper.ReleaseConnections();
// MAP INPUT COLUMNS
foreach (IDTSInput100 input in destinationComponent.InputCollection)
IDTSVirtualInput100 virtualInput = input.GetVirtualInput();
foreach (IDTSVirtualInputColumn100 virtualInputColumn in virtualInput.VirtualInputColumnCollection)
Console.WriteLine("VIC " + virtualInputColumn.Name + "(" + virtualInputColumn.ID + ")");
destinationComponentWrapper.SetUsageType(input.ID, virtualInput, virtualInputColumn.LineageID, DTSUsageType.UT_READONLY);
foreach (IDTSExternalMetadataColumn100 metadataColumn in input.ExternalMetadataColumnCollection)
if (virtualInputColumn.Name.Equals(metadataColumn.Name)) {
// PROBLEM HERE:
// An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in msdatapipe.exe
// Additional information: Exception HRESULT: 0xC0047072
// at this point is virtualInputColumn.ID = -2147483573
destinationComponentWrapper.MapInputColumn(input.ID, virtualInputColumn.ID, metadataColumn.ID);
// if the code is commented out and the program rerun there is a package validation error instead: 0xC020201B
// 0xC020201B - The number of input columns for Flat File Destination.Inputs[Flat File Destination Inputs] cannot be zero
// NEED TO CREATE META DATA AFTER COLUMNS HAVE BEEN ADDED TO THE DESTIONATION MANAGER
// AND USAGE TYPE HAS BEEN SET OR WE'LL GET A VS_NEEDSNEWMETADATA
destinationComponentWrapper.AcquireConnections(null);
destinationComponentWrapper.ReinitializeMetaData();
destinationComponentWrapper.ReleaseConnections();
// SAVING DTSX PACKAGE FOR DEBUGGING
application.SaveToXml("C:\\Users\\CMI\\documents\\visual studio 2010\\Projects\\SSIS Tutorial\\SSIS Tutorial\\generated.dtsx", package, null);
Microsoft.SqlServer.Dts.Runtime.DTSExecResult packageResults = package.Execute();
Console.WriteLine("package execution result: " + packageResults.ToString());
// Basic check for errors
foreach (DtsError error in package.Errors)
Console.WriteLine("ErrorCode : 0x{0:X}", error.ErrorCode);
Console.WriteLine(" SubComponent : {0}", error.SubComponent);
Console.WriteLine(" Description : {0}", error.Description);
Console.WriteLine("press the return key hard to continue...");
Console.Read();

I suggest you revise your code against examples given in http://blogs.msdn.com/b/mattm/archive/2008/12/30/samples-for-creating-ssis-packages-programmatically.aspx
Arthur My Blog

Similar Messages

  • A Required COM Add-in program for XL Reporter has not been loaded and ....

    A Required COM Add-in program for XL Reporter has not been loaded and prohibits Microsoft Excel from running. For more information, click help.
    XL 2007, with the Trust level for macros set to minimum. SBO 2007 PL 42.
    Thanks
    Charles

    Read the following solution from SAP for your problem:
    When we open XL Reporter we get an error
    message "A required COM add-in program for XL Reporter has not been loaded
    and prohibits Microsoft Excel from running." when trying to open a report
    definition.
    SOLUTION FOR THE PROBLEM:
    Reason and Prerequisites
    You need to be an administrator on the local machine to add COM add-ins.
    Solution
    The user should be added as a member of the administrator role on the
    local computer the first time you start Excel from XL Reporter the first
    time so that the COM addin are registered, then you can remove the user
    from the administrator group again.
    Manually Loading the XL Reporter Excel COM Add-In
    Symptom
    If you install Microsoft Office after installing the XL Reporter
    application or use another Windows user than the one you used when
    installing XL Reporter, you can get an error message.
    Reason and Prerequisites
    The reason for this is that the report writer COM Add-in has not been
    loaded, which prohibits Microsoft Excel from running.
    Solution
    1. Start Microsoft Excel. If you already have the COM Add-ins command on
    the Tools menu, go to step 7.
    2. In the Tools menu, choose Customize.
    This opens the Customize window.
    3. Choose the Commands tab and select Tools from the Categories pane on
    the left.
    4. In the Command pane on the right, scroll down to the COM Add-ins
    command.
    5. Select the COM Add-ins command, hold down the mouse button, and drag
    COM Add-ins from the Commands pane over to the Tools menu on the Microsoft
    Excel men bar. When the Tools menu commands appear, point to where you
    want the COM Add-ins command to appear on the menu and release the mouse
    button.
    6. To close the Customize window, choose Close.
    7. On the Tools menu, choose the new COM Add-ins option.
    This opens the COM Add-ins window.
    8. In the window, choose Add to open the Add Add-in window.
    9.Select the IXXLReporter.dll file located in the Client directory in the
    XL Reporter program installation area and choose OK.
    10. In the COM Add-ins window, select the XL Reporter checkbox and choose
    OK.

  • Difference between batch input method and batch input recording in LSMW?

    hi,
    plz tell me the difference between batch input method and batch input recording in LSMW?
    thanks & regards
    Ruban

    Hi Ruban,
               The main difference between the two is in lsmw we can view the code status at any time just by coming to prvious steps, but whereas in batch input method unless the recording is finished we cant view the code.
    second diff is tht we need to do lot of coding in batch inptu whereas here in lsmw we need not do much coding and mapping to data.
    third diff is that batch input is both inbound and outbound where as lsmw is only inbound.
    hope u got the differences.....
    Regards,
    sana M...

  • Difference between batch input method and direct input method in LSMW.

    Hi all,
    what is difference between batch input method and direct input method in LSMW. are they same?if differences are there tell me with details?

    Hi,
    Here are few differences bw Batch Input and Direct Inputs methods.
    Batch Input: Uses classical BDC approach, but doesn't required an ABAP program to be written to format the BDC DATA. The user has to format the data using predefined structures and store it in a flat file. Yet it is a slower updation method.
    Direct Input: Works similar to Batch Input programs. The difference is, instead of processing screens they validate fields and directly load the data into tables using standard function modules. Much faster and suits for large volume of data.
    Thanks.
    DhanaLakshmi M S

  • HT4009 I made a in app purchase on a game and it never took, when I went back and tried it again a window popped up that said I have already purchased this item but has not been downloaded yet? How do I download it when there is not a option to download?

    I made a in app purchase on a game and it never took, when I went back and tried it again a window popped up that said I have already purchased this item but has not been downloaded yet? How do I download it when there is not a option to download?

    Hi Dave_warr,
    I would suggest restarting the iPad and see if the download resumes.
    iTunes: How to resume interrupted iTunes Store downloads
    Resuming downloads from an iOS device
    From the Home screen, tap the iTunes icon.
    For iPhone/iPod touch, tap More > Downloads. For iPad, tap Downloads.
    Enter your account name and password.
    Click the "OK" button.
    Click the Resume or Resume All button to start the download.
    If you don't see the application to download it, then follow these troubleshooting steps:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    If the app does not appear in your list of purchases, then contact the iTunes Store for help:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBookstore purchase
    I hope this information helps ....
    Have a great day!
    - Judy

  • I have tried to update the software on my ipad 2, 16GB,  through itunes, but the update has not been completed and has frozen, what should I do?

    I have tried to update the software on my ipad 2, 16GB,  through itunes, but the update has not been completed and has frozen, what should I do?

    Hey there alaili55,
    Welcome to Apple Support Communities.
    It sounds like you ran into an issue updating your iPad 2 with iTunes on your computer. Take a look at the article linked below and try the troubleshooting tips that it provides, which will resolve most issues updating iOS devices.
    Resolve iOS update and restore errors in iTunes - Apple Support
    Cheers,
    -Jason

  • HT3702 I have an order that has not been completed and the old card no longer exists and I want to pay with my new card. the order is MHBG5FL5DH How do I delete the restriction in iTunes

    I have an order that has not been completed and the old card no longer exists and I want to pay with my new card. the order is MHBG5FL5DHHow do I delete the restriction in iTunes

    You need to ask Apple to reset your security questions. To do this, click here and pick a method; if that page doesn't list one for your country or you're unable to call, fill out and submit this form.
    (122986)

  • TS4000 I have been away for 2 weeks and a message appears on my iPad which is preventing me open my iPad. "iCloud backup. This iPad has not been backed up in 2 weeks. Backups happen when this iPad is plugged in, locked and connected to Wi-Fi"  Help?

    I have been away for 2 weeks and a message appears on my iPad which is preventing me open my iPad. "iCloud backup. This iPad has not been backed up in 2 weeks. Backups happen when this iPad is plugged in, locked and connected to Wi-Fi"  Help?
    What do I do to get rid of this message as it is preventing me accessing the iPad or closing it down?
    Thanks
    AndyNess59

    Welcome to Apple Support Communities
    Hold Sleep and Home buttons for 10 seconds until your device restarts, so you will be able to use your device again. Finally, open Settings > iCloud > Storage & Backup, and make a backup. The device will be backed up when it's plugged to the charger and connected to your network

  • TS4268 Hello, it's been 5 days now since my imessage has not working..and i have chatted to the costumer for two times. I took thier advice and instructions just to enable to send and receive on it but unfortunately until now its still NOT working. Pls.he

    Hello, it's been 5 days now since my imessage has not working..and i have chatted to the costumer for two times. I took thier advice and instructions just to enable to send and receive on it but unfortunately until now its still NOT working. Is there anybody who could help me please?

    Try this even if you have already.  Just make sure to follow the steps specifically.
    Go to settings > Facetime > send and recieve > tap on your apple id and sign out.  If your not signed in then that will work as well.
    Go to settings > Messages > sent and recieve > tap on your apple id and sign out.
    Restart the iPad by doing the slide to power off setup.  Just hold the power button on the top right till it turns off.
    After the iPad has been restarted:
    Go to settings > Facetime > and sign in
    Go to settings > Messages > and sign in
    Wait about 3 min then restart the iPad again.  Same instructions as above.
    When you restart you should be able to use messages again.  If not then call support again and talk to someone higher than the first level support they have.

  • Excel cannot open the file beacuse the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file [help]

    Hi,
    I have a excel file that I have been using since beginning of year.
    Yesterday, I tried to open it but a message comes out "
    Excel cannot open the file beacuse the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file"
    After I click yes, the page is blank. The file is about 400kb in size.
    I have try open and repair and third party repair program and not working also.
    I would appreciate a lot if you can help me.
    Thank you very much.

    Per your post, this problem might be caused by malware on the affected machine.
    http://blogs.technet.com/b/the_microsoft_excel_support_team_blog/archive/2013/09/07/quot-cannot-open-the-file-because-the-file-format-or-extension-is-invalid-quot-opening-office-files.aspx
    In order to clean your machine, run Microsoft Safety Scanner (http://www.microsoft.com/security/scanner/en-us/default.aspx) to kill the malware, and then repair Excel file itself.
    If this is not the case, feel free to post back and let me know. Thanks.
    Tony Chen
    TechNet Community Support
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • I am Greek. I downloaded a film from ipad but for the last days it has not been downloaded and the status is "waiting".the charge has been made to my credit card. Does any body knows?

    I am Greek. I purchased a film from ipad but for the last days it has not been downloaded and the status is "waiting".the charge has been made to my credit card. Does any body knows?

    something other is dowloading somewhere on ipad

  • TS4036 iCloud Back up Error   This iPad has not been backed up in 2 weeks.  Backups happen when this iPad is plugged  in, locked and connected to Wi-Fi.  I am unable to shut off my iPad or even do anything on it.  It will not let me get past this error.

    I have an Icloud back up error.  It will not let me shut off the device or do anything.  It is locked.  The error is:  This iPad has not been backed up for 2 weeks. Backups happen when it is plugged in, locked or connected to Wi-Fi.
    Please help me get this working again.
    Thank you.
    Beno Plumbing

    Welcome to Apple Support Communities
    Hold Sleep and Home buttons for 10 seconds until your iPad restarts, so you will be able to use the iPad again. Finally, open Settings > iCloud > Storage & Backup to make a manual backup

  • Hello I have a mac book pro (lap top) and it's version is 10.6.8.i want to up grade it to 10.9.2. version .i downloaded version from apple store twice and it is un able to installing; give me error massage of installing.the error has not any number and it

    Hello
    I have a mac book pro (lap top) and it’s version is 10.6.8.i want to up grade it to 10.9.2. version .i downloaded version from apple store twice and it is un able to installing; give me error massage of installing.the error has not any number and it says :installation can not be complete with a red sign. please say the solution.also how i can get  the 7.0.0. version up date from apple store . i searched very much but i did not find the version .

    What MacBook Pro model do you have?  Check the apple, left side of the menu bar, About This Mac, More Info, System Report, Hardware and then the Model Identifier...has to be at least MacBook Pro3,1 to install Mavericks.

  • HT1320 Hi, I have an Ipod nano which is nearly 12mths old. Recently ths shuffle aspect has not been working and the same piece  of music plays over and over and can only move onto the next music only by pressing the manual button to move onto the next mus

    Hi
    I have an Ipod nano which is nearly 12mths old. Recently the shuffle aspect has not been working and I have to manually press the forward arrows on the screen to move onto the next piece of music. If i dont press the forward arrows the same piece of music plays over and over.
    regards
    jamie

    Hello
    Tap the screen when playing a song and you should see playback options and tap the repeat until it is white. When it is blue it on repeat and if it has a 1 on it then it is repeating the same song over and over again.
    iPod Nano
    http://manuals.info.apple.com/MANUALS/1000/MA1624/en_US/ipod_nano_user_guide.pdf
    Regards,
    -Norm G.

  • My App Store has not been working and every time I hit it its just blank what do I do

    DDear Apple my App Store has not been working and i need to know what to do because I need to download things and I cant every time I touch the button it's just blank

    iOS: Resolving update and restore alert messages
    For error -50: See error 13 and 14: 
    Error 13 and 14: These errors are typically resolved by performing one or more of the steps listed below:
    Perform USB isolation troubleshooting, including trying a different USB port directly on the computer. See the advanced steps below for USB troubleshooting.
    Put a USB 2.0 hub between the device and the computer.
    Try a different USB 30-pin dock-connector cable.
    Eliminate third-party security software conflicts.
    There may be third-party software installed that modifies your default packet size in Windows by inserting one or more TcpWindowSize entries into your registry. Your default packet size being set incorrectly can cause this error. Contact the manufacturer of the software that installed the packet-size modification for assistance. Or, follow this article by Microsoft: How to reset Internet Protocol (TCP/IP) to reset the packet size back to the default for Windows.
    Connect your computer directly to your Internet source, bypassing any routers, hubs, or switches. You may need to restart your computer and modem to get online.
    Try to restore from another known-good computer and network.

Maybe you are looking for