[EzAPI] How to working with EzDerivedColumn?

Answered [EzAPI] How to working with EzDerivedColumn?

  • Monday, February 04, 2013 10:52 PM
     
     

    hi!

    I try to use the class EzDerivedColumn from the EzAPI project. I want to create a new column and concatenate two input columns like: Col1 + "//" + Col2. I can create the new column but if i try to set the "FriendlyExpression" i get always an error. Any little example for me please?

    Thanks!

    Andreas

All Replies

  • Tuesday, February 05, 2013 5:56 PM
    Moderator
     
     

    What is the error?


    Arthur My Blog

  • Tuesday, February 05, 2013 5:57 PM
    Moderator
     
     
    See code in https://sqlsrvintegrationsrv.svn.codeplex.com/svn/main/EzAPI/src/EzComponents.cs looks like this is what you need.

    Arthur My Blog

  • Tuesday, February 05, 2013 8:23 PM
     
     

    Thanks for reply

    #1

     // i can set the friendly expression this way, but the value isn't forwarded and modifed into the expression property, so the component isn't in a useabled state
     EzDerivedColumn ezDerivedColumn = new EzDerivedColumn(this);
     ezDerivedColumn.InsertOutputColumn("NewCol");
     ezDerivedColumn.SetOutputColumnDataTypeProperties("NewCol", DataType.DT_WSTR, cc.Length, 0, 0, 0);
     ezDerivedColumn.AttachTo(AdoSource);
     ezDerivedColumn.Name = "Create derived columns";                   
     IDTSOutputColumn100 dummy = ezDerivedColumn.OutputCol("NewCol");
     dummy.CustomPropertyCollection["FriendlyExpression"].Value = "Col1 + Col2";
     

    #2

     // if i set the friendly expression this way, i get an COMException HRESULT: 0xC0048004
     EzDerivedColumn ezDerivedColumn = new EzDerivedColumn(this);
     ezDerivedColumn.InsertOutputColumn("NewCol");
     ezDerivedColumn.SetOutputColumnDataTypeProperties("NewCol", DataType.DT_WSTR, cc.Length, 0, 0, 0);
     ezDerivedColumn.AttachTo(AdoSource);
     ezDerivedColumn.Name = "Create derived columns";                   
     IDTSOutputColumn100 dummy = ezDerivedColumn.OutputCol("NewCol");
     ezDerivedColumn.SetOutputProperty(dummy.ID, "FriendlyExpression", "Col1 + Col2");

     //stack trace 
        bei Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSOutputCollection100.get_Item(Object Index)
       bei Microsoft.SqlServer.SSIS.EzAPI.EzComponent.SetOutputProperty(Int32 outputIndex, String propName, Object propValue)

       // i get the same error if i try to set the "Expresion" property:
       ezDerivedColumn.SetOutputProperty(dummy.ID, "Expression", "Col1 + Col2");

    I've checked the ezapi sources but unfortunately it doesn't help me by this error...

    Andreas









  • Wednesday, February 13, 2013 9:11 AM
    Moderator
     
     Answered

    Hi Andreas Schneider,GER,

    It seems that the index is not valid. These COM Exceptions will provide you with an HRESULT (ErrorCode), and no additional information, you’ll need to be able to modify the package generation code (or at least control the TaskHost and MainPipe of the data flow objects). You’ll receive detailed error messages by supplying an IDTSComponentEvents handler for the IDTSPipeline100.Events property. The FireError event will be raised right before any COMException is thrown, proving you the error details. Please refer to: http://blogs.msdn.com/b/mattm/archive/2009/08/03/debugging-a-comexception-during-package-generation.aspx

    Thanks,
    Eileen

    If you have any feedback on our support, please click here


    Eileen Zhao
    TechNet Community Support

  • Monday, April 15, 2013 9:48 AM
     
     

    Thanks for reply

    #1

     // i can set the friendly expression this way, but the value isn't forwarded and modifed into the expression property, so the component isn't in a useabled state
     EzDerivedColumn ezDerivedColumn = new EzDerivedColumn(this);
     ezDerivedColumn.InsertOutputColumn("NewCol");
     ezDerivedColumn.SetOutputColumnDataTypeProperties("NewCol", DataType.DT_WSTR, cc.Length, 0, 0, 0);
     ezDerivedColumn.AttachTo(AdoSource);
     ezDerivedColumn.Name = "Create derived columns";                   
     IDTSOutputColumn100 dummy = ezDerivedColumn.OutputCol("NewCol");
     dummy.CustomPropertyCollection["FriendlyExpression"].Value = "Col1 + Col2";
     

    Also set the "Expression" property - as least with the currently modified version of EzApi I have (which fixes a few bugs on the original code) it works as expected

    dummy.CustomPropertyCollection["Expression"].Value = "Col1 + Col2";