I have a Script component (Script Transformation), which I need to be able to fail the DFT, i.e. the Data Flow Task that it is part of.
I am firing an error like this
try
{
// Does some work here, which can fail...
}
catch (Exception ex)
{
bool pbCancel = false;
this.ComponentMetaData.FireError(0, Variables.TaskName, "Error message: " + ex.Message, String.Empty, 0, out pbCancel);
}
However, FireError does not cause the task to fail.
Note that this is a script component inside a data transformation task - not a script task.
What do I do to fail this task from the script component?
A Script task runs custom code at some point in the package workflow. Unless you put it in a loop container or an event handler, it only runs once. A Script component also runs once, but typically it runs its main processing routine once for each row of data in the data flow.
The Script Component provides another area where programming logic can be applied in an SSIS package. This component, which can be used only in the Data Flow portion of an SSIS package, allows programmatic tasks to occur in the data stream. This component exists to provide, consume, or transform data using . NET code.
The Dts object is an instance of the ScriptObjectModel class. ScriptTask. Defines the classes for the Script task, which lets developers write custom code to perform functions that are not available in the built-in tasks provided by Integration Services.
Configuring the Script TaskProvide the custom script that the task runs. Specify the method in the VSTA project that the Integration Services runtime calls as the entry point into the Script task code. Specify the script language. Optionally, provide lists of read-only and read/write variables for use in the script.
In your example you are catching the exception but not throwing it. Just add
catch (Exception ex)
{
// ... your other code here
throw ex;
}
and the component will fail.
This should be what you're looking for - 2008 R2 C# script component.
bool fireAgain = true;
IDTSComponentMetaData100 myMetaData;
myMetaData = this.ComponentMetaData;
//for information
myMetaData.FireInformation(0, "SubComponent", "Description", string.Empty, 0, ref fireAgain);
//for error
myMetaData.FireError(0, "SubComponent", ex.Message.ToString() + ex.StackTrace, string.Empty, 0, out fireAgain);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With