user1428779
user1428779

Reputation: 23

SSIS Script Component FireError DNE in Current Context

I am trying to add some more native error handling to an SSIS C# Script Component (in Data-Flow). Right now I force it to crash the component with 1/0 which works but is hackish.

My script does some jazz on input data, but I would like to validate it at several steps and fail the component if any validations fail. The source is a select, so i don't need to roll back any transactions etc... but I would like the component to fail the dataflow so the dataflow component will fail and follow the error handling I prescribe in control flow.

Here is the simplist relavant snippet that is holding me up:

using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;

[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{


public override void PreExecute()
{
    base.PreExecute();
    /*
      Add your code here for preprocessing or remove if not needed
    */

    bool pbCancel = false;
    ////check Row Count>0
    if (Variables.WeeklyLRrowCount == 0)
        this.ComponentMetaData.FireError(-1, "", "Fails Validation due to Empty Table.", "", 0, out pbCancel);
}

public override void PostExecute()
{
    base.PostExecute();
    /*
      Add your code here for postprocessing or remove if not needed
      You can set read/write variables here, for example:
      Variables.MyIntVar = 100
    */

}

public override void Input0_ProcessInputRow(Input0Buffer Row)
{
    /*
      Add your code here
    */

}


}

I get the following from SSIS:

"The name 'FireError' does not exist in the current context."

Is there something I am missing here?

Thanks!

Upvotes: 2

Views: 3234

Answers (2)

William Salzman
William Salzman

Reputation: 6446

"Typically, during component design, the FireError, FireInformation, and FireWarning methods are called to provide user feedback when a component is incorrectly configured."

http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.idtscomponentevents(v=sql.105).aspx

If I read this correctly this is not for runtime use in a script task, but during design time use of a custom component to indicate configuration errors.

This code from http://msdn.microsoft.com/en-us/library/ms135912(v=sql.105).aspx may be what you want.

public override void RegisterEvents()
{
string [] parameterNames = new string[2]{"RowCount", "StartTime"};
ushort [] parameterTypes = new ushort[2]{ DtsConvert.VarTypeFromTypeCode(TypeCode.Int32),   DtsConvert.VarTypeFromTypeCode(TypeCode.DateTime)};
string [] parameterDescriptions = new string[2]{"The number of rows to sort.", "The start time of the Sort operation."};
EventInfos.Add("StartingSort","Fires when the component begins sorting the rows.",false,ref parameterNames, ref paramterTypes, ref parameterDescriptions);
}
public override void ProcessInput(int inputID, PipelineBuffer buffer)
{
while (buffer.NextRow())
{
   // Process buffer rows.
}

IDTSEventInfo100 eventInfo = EventInfos["StartingSort"];
object []arguments = new object[2]{buffer.RowCount, DateTime.Now };
ComponentMetaData.FireCustomEvent("StartingSort", "Beginning sort operation.", ref arguments, ComponentMetaData.Name, ref FireSortEventAgain);
}

Upvotes: 0

chahi
chahi

Reputation: 36

You should just move your code to the PostExecute method.

Upvotes: 2

Related Questions