Bruno Gomes Bruno Gomes - 6 months ago 52
C# Question

SSIS Custom transformation receive variable

I am creating a custom transformation in C# to be used in SSIS. I have already been able creating and adding the custom component and receive and alter data from a db source but I need more data to register in a log table. This data can only be passed with variables but I can't find a good explanation of how to add a

to my component.

I have tried to use IDTSVariable100 and VariableDispenser but I can't make sense of how to.

public override void ProvideComponentProperties()
VariableDispenser varDispenser = this.VariableDispenser();

IDTSVariable100 vr = this.VariableDispenser.GetVariables();
IDTSInput100 input = this.ComponentMetaData.InputCollection.New();
input.Name = "Input_B";

IDTSOutput100 output=this.ComponentMetaData.OutputCollection.New();
output.Name = "Output_B";

// the output is synchronous with the input
output.SynchronousInputID = input.ID;


Basically i want to define
that I can alter the value before my custom component runs like the original "script component" has.


Well i researched a bit more and stumbled on a answer: It seems that to access the SSIS public variables we have to get them with code on the ProcessInput Method:

var dimSrcId ="";

IDTSVariables100 variables = null;


this.VariableDispenser.GetVariables(out variables);

dimSrcId = variables["User::dimSrcId"].Value.ToString();


By using the VariableDispenser.LockForRead() we're capable of searching for our variables and access there value.