次の方法で共有


TaskHost.SetExpression メソッド

指定した式をプロパティに割り当てます。 既存の式をプロパティから削除するには、nullNULL 参照 (Visual Basic では Nothing) を指定します。

名前空間:  Microsoft.SqlServer.Dts.Runtime
アセンブリ:  Microsoft.SqlServer.ManagedDTS (Microsoft.SqlServer.ManagedDTS.dll)

構文

'宣言
Public Sub SetExpression ( _
    propertyName As String, _
    expression As String _
)
'使用
Dim instance As TaskHost 
Dim propertyName As String 
Dim expression As String

instance.SetExpression(propertyName, _
    expression)
public void SetExpression(
    string propertyName,
    string expression
)
public:
virtual void SetExpression(
    String^ propertyName, 
    String^ expression
) sealed
abstract SetExpression : 
        propertyName:string * 
        expression:string -> unit  
override SetExpression : 
        propertyName:string * 
        expression:string -> unit
public final function SetExpression(
    propertyName : String, 
    expression : String
)

パラメーター

  • propertyName
    型: System.String
    式を割り当てるプロパティの名前です。

実装

IDTSPropertiesProvider.SetExpression(String, String)

説明

propertyName には、オブジェクトで使用可能な任意のプロパティを指定できます。

使用例

次のコード例は、TaskHost の SetExpression メソッドと GetExpression メソッドの使用方法を示します。 このコード例では、BulkInsertTask がホストされるタスクです。

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


namespace Microsoft.SqlServer.SSIS.Sample
{
    class Program
        {
        static void Main(string[] args)
        {
            Package pkg = new Package();
            TaskHost th = (TaskHost)pkg.Executables.Add("STOCK:BulkInsertTask");

            // View information about the CheckConstraints property
            // before setting it using the SetExpression method.
            Boolean checkConstraint = (Boolean)th.Properties["CheckConstraints"].GetValue(th);
            Console.WriteLine("Original value of CheckConstraints: {0}", checkConstraint);

            // Use SetExpression to set the value to true.
            String myTrueString = "true";
            th.Properties["CheckConstraints"].SetExpression(th, myTrueString);

            // 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.
            checkConstraint = (Boolean)th.Properties["CheckConstraints"].GetValue(th);
            String myExpression = th.Properties["CheckConstraints"].GetExpression(th);
            Console.WriteLine("New value of CheckConstraints: {0}", checkConstraint);
            Console.WriteLine("Expression for CheckConstraints: {0}", myExpression);
        }
    }
}

サンプル出力:

Original value of CheckConstraints: False

New value of CheckConstraints: True

Expression for CheckConstraints: true

関連項目

参照

TaskHost クラス

Microsoft.SqlServer.Dts.Runtime 名前空間