locked
Adding variables from a source component throws a COMException RRS feed

  • Question

  • I'm trying to add variables programmatically from my source component for the header row in a CSV file, but whenever I try to execute the following code, it throws a COMException (HReult: 0xC0010014), I have tried several different methods, but each time I try to add the variable (either using the wrapper class Variables or the actual interface IDTSVariables100), it throws the same exception.  Anyone have an idea?
    IDTSVariables100 variables;
    this.VariableDispenser.GetVariables(out variables);
    variables.Add(variableName, false, "", value);

    Daniel - http://webs.neumont.edu/dstafford
    Monday, April 6, 2009 10:15 PM

Answers

  • I'm pretty sure (though I'm open to being proven wrong) that you can't do this. The variable dispenser is for getting access to the existing variables, not for adding new ones. The way to handle this would be to provide an option in your component for selecting an existing package variable, or even providing a UI that allows you to add the variables. You have more access to the package strucutures from a custom component UI. This also helps guarantee that you can't modify the package at runtime.
    John Welch | www.mariner-usa.com | www.agilebi.com | ssisUnit.codeplex.com
    • Proposed as answer by jwelch Tuesday, April 7, 2009 3:40 PM
    • Marked as answer by Tony Tang_YJ Friday, April 17, 2009 9:34 AM
    Tuesday, April 7, 2009 2:29 AM

All replies

  • I'm pretty sure (though I'm open to being proven wrong) that you can't do this. The variable dispenser is for getting access to the existing variables, not for adding new ones. The way to handle this would be to provide an option in your component for selecting an existing package variable, or even providing a UI that allows you to add the variables. You have more access to the package strucutures from a custom component UI. This also helps guarantee that you can't modify the package at runtime.
    John Welch | www.mariner-usa.com | www.agilebi.com | ssisUnit.codeplex.com
    • Proposed as answer by jwelch Tuesday, April 7, 2009 3:40 PM
    • Marked as answer by Tony Tang_YJ Friday, April 17, 2009 9:34 AM
    Tuesday, April 7, 2009 2:29 AM
  • Yeah, I was afraid of that, I have changed it to use existing variables, but it would have been nicer to be able to add variables at run-time.  Oh well...
    Daniel - http://webs.neumont.edu/dstafford
    Tuesday, April 7, 2009 1:37 PM
  • Why would you want to add variables at run-time - when no other component would know those variables existed?  There seems to be no point...
    Todd McDermid's Blog
    Tuesday, April 7, 2009 3:39 PM