DtsEventHandler.SetExpression Method (String, String)


Assigns the specified expression to the property. Specify null to remove an existing expression from the property.

Namespace:   Microsoft.SqlServer.Dts.Runtime
Assembly:  Microsoft.SqlServer.ManagedDTS (in Microsoft.SqlServer.ManagedDTS.dll)

public void SetExpression(
	string propertyName,
	string expression


Type: System.String

The name of the property to which to assign the expression.

Type: System.String

The expression.

The following code example creates a package and adds a DtsEventHandler for the package OnError event. Using the SetExpression, the FailParentOnFailure property is modified. Using the GetExpression method, the new value and associated expression are displayed.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;

namespace Microsoft.SqlServer.SSIS.Sample
    class SSISProgram
        static void Main(string[] args)
            Package pkg = new Package();
            // Set up a DtsEventHandler for the package OnError event.
            DtsEventHandler dtsEH = (DtsEventHandler)pkg.EventHandlers.Add("OnError");

            // Show the value of DebugMode on the container before modifying it.
            Console.WriteLine("Original FailParentOnFailure = {0}", dtsEH.FailParentOnFailure);

            // Use SetExpression to set DebugMode to "true".
            String myExpression = "True";
            dtsEH.SetExpression("FailParentOnFailure", myExpression);

            //Validate the package to set the expression onto the property.
            DTSExecResult valResult = pkg.Validate(null, null, null, null);

            // Retrieve the new value and the expression.
            String myNewExpression = dtsEH.GetExpression("FailParentOnFailure");
            Console.WriteLine("New value of FailParentOnFailure: {0}", dtsEH.FailParentOnFailure);
            Console.WriteLine("Expression for FailParentOnFailure: {0}", myNewExpression);

Sample Output:

Original FailParentOnFailure = False

New value of FailParentOnFailure: True

Expression for FailParentOnFailure: True

Return to top