DtsEventHandler.SetExpression(String, String) メソッド

定義

指定した式をプロパティに割り当てます。 プロパティから既存の式を削除するには、null を指定します。

public:
 virtual void SetExpression(System::String ^ propertyName, System::String ^ expression);
public void SetExpression (string propertyName, string expression);
abstract member SetExpression : string * string -> unit
override this.SetExpression : string * string -> unit
Public Sub SetExpression (propertyName As String, expression As String)

パラメーター

propertyName
String

式を割り当てるプロパティの名前です。

expression
String

式。

実装

次のコード例では、パッケージを作成し、パッケージの OnError イベントの DtsEventHandler を追加します。 SetExpression を使用して、FailParentOnFailure プロパティを変更します。 GetExpression メソッドを使用して、新しい値と関連する式を表示します。

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);  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Class SSISProgram  

    Shared Sub Main(ByVal args() As String)   
        Dim pkg As New Package()  
        ' Set up a DtsEventHandler for the package OnError event.  
        Dim dtsEH As DtsEventHandler = CType(pkg.EventHandlers.Add("OnError"), DtsEventHandler)  

        ' 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".  
        Dim myExpression As String = "True"  
        dtsEH.SetExpression("FailParentOnFailure", myExpression)  

        'Validate the package to set the expression onto the property.  
        Dim valResult As DTSExecResult = pkg.Validate(Nothing, Nothing, Nothing, Nothing)  

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

    End Sub 'Main  
End Class  

サンプル出力:

Original FailParentOnFailure = False

New value of FailParentOnFailure: True

Expression for FailParentOnFailure: True

適用対象