Have to refresh Package tasks after creating programmatically

  • Hi,

    I am building some ssis package programatically. My Sources are csv-files. The generated Package worsk not immeidately. I have to open it in BIDS and open the tasks in the dataflow. While doing this, I think some metadata is refreshed.

    For example, when i run the package after its generation i get the error that derived columns expressions are empty. After i have opened and closed the derived column task, they are filled.

    I'm looking for the error in my code. Help is very appreciated..

    IDTSComponentMetaData100 derivedColumn = dataFlow.ComponentMetaDataCollection.New();

    derivedColumn.ComponentClassID = "DTSTransform.DerivedColumn";

    CManagedComponentWrapper instance = derivedColumn.Instantiate();

    instance.ProvideComponentProperties();

    // Set the properties after the component has provided the component properties.

    derivedColumn.Name = "Derived Column";

    derivedColumn.Description = "Beschreibung";

    derivedColumn.OutputCollection[0].TruncationRowDisposition = DTSRowDisposition.RD_NotUsed;

    derivedColumn.OutputCollection[0].ErrorRowDisposition = DTSRowDisposition.RD_NotUsed;

    IDTSPath100 dpath = dataFlow.PathCollection.New();

    dpath.AttachPathAndPropagateNotifications(srcComponent.OutputCollection[0], derivedColumn.InputCollection[0]);

    // Get the derived's default input and virtual input.

    IDTSInput100 input = derivedColumn.InputCollection[0];

    IDTSVirtualInput100 derivedInputVirtual = input.GetVirtualInput();

    IDTSCustomProperty100 property = null;

    // Iterate through the virtual input column collection.

    foreach (IDTSVirtualInputColumn100 vColumn in derivedInputVirtual.VirtualInputColumnCollection)

    {

    instance.SetUsageType(input.ID, derivedInputVirtual, vColumn.LineageID, DTSUsageType.UT_READWRITE);

    }

    foreach (IDTSInputColumn100 inputColumn in derivedColumn.InputCollection[0].InputColumnCollection)

    {

    /**

    * für jede Datumspalte muss das Format yyyymmdd in ein DB_DATE konvertiert werden. Dafür eine abgeleitete Spalte bilden

    */

    if (dbfReader.GetField(inputColumn.Name).fieldType == 'D')

    {

    String dateExpr = "LEN("+inputColumn.Name+") < 8 ? NULL(DT_DATE) : (DT_DATE)((SUBSTRING((DT_WSTR,8)" + inputColumn.Name + ",5,2) + \"-\" + SUBSTRING((DT_WSTR,8)" + inputColumn.Name + ",7,2) + \"-\" + SUBSTRING((DT_WSTR,8)" + inputColumn.Name + ",1,4)))";

    [....]

  • Have you executed the AquireConnection method on the wrapper in your code? Essentially, that's what happens when you open the connection component in your data flow.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply