Freigeben über


Package.SetExpression Method

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)

Syntax

'Declaration
Public Sub SetExpression ( _
    propertyName As String, _
    expression As String _
)
public void SetExpression (
    string propertyName,
    string expression
)
public:
virtual void SetExpression (
    String^ propertyName, 
    String^ expression
) sealed
public final void SetExpression (
    String propertyName, 
    String expression
)
public final function SetExpression (
    propertyName : String, 
    expression : String
)

Parameter

  • propertyName
    The name of the property to assign the expression to.
  • expression
    The expression.

Hinweise

The propertyName can be any property available on the object.

Beispiel

The following code example modifies the value of the DelayValidation property using SetExpression, then displays the new value using GetExpression.

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

namespace Microsoft.SqlServer.SSIS.Samples
{
    class Program
    {
        static void Main(string[] args)
        {
            Package pkg = new Package();
            // Set an expression on one of the properties.
            DtsProperties pkgProperties = pkg.Properties;

            // View information about the DelayValidation property 
            // before setting it with the SetExpression method.
            Object myValue = pkgProperties["DelayValidation"].GetValue(pkg);
            String mySValue = myValue.ToString();
            Console.WriteLine("value before is {0}", mySValue); 
            
            // Use SetExpression to set the value to true.
            String myTrueString = "true";
            pkgProperties["DelayValidation"].SetExpression(pkg, myTrueString);

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

            // Verify the new setting.
            myValue = pkgProperties["DelayValidation"].GetValue(pkg);
            mySValue = myValue.ToString();

            String myExpression = pkg.Properties["DelayValidation"].GetExpression(pkg);
            String mySExpression = myExpression.ToString();
            Console.WriteLine("The value and expression is {0}, {1}", mySValue, mySExpression);
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime

Class Program
    Shared Sub Main(ByVal args() As String) 
        Dim pkg As New Package()
        ' Set an expression on one of the properties.
        Dim pkgProperties As DtsProperties = pkg.Properties
        
        ' View information about the DelayValidation property 
        ' before setting it with the SetExpression method.
        Dim myValue As [Object] = pkgProperties("DelayValidation").GetValue(pkg)
        Dim mySValue As String = myValue.ToString()
        Console.WriteLine("value before is {0}", mySValue)
        
        ' Use SetExpression to set the value to true.
        Dim myTrueString As String = "true"
        pkgProperties("DelayValidation").SetExpression(pkg, myTrueString)
        
        ' Validate the package to set the expression onto the property.
        Dim valResult As DTSExecResult = pkg.Validate(Nothing, Nothing, Nothing, Nothing)
        
        ' Verify the new setting.
        myValue = pkgProperties("DelayValidation").GetValue(pkg)
        mySValue = myValue.ToString()
        
        Dim myExpression As String = pkg.Properties("DelayValidation").GetExpression(pkg)
        Dim mySExpression As String = myExpression.ToString()
        Console.WriteLine("The value and expression is {0}, {1}", mySValue, mySExpression)
    End Sub
End Class

Sample Output:

value before is False

The value and expression is True, true

Threadsicherheit

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Plattformen

Entwicklungsplattformen

Eine Liste der unterstützten Plattformen finden Sie unterHardware- und Softwareanforderungen für die Installation von SQL Server 2005.

Zielplattforme

Eine Liste der unterstützten Plattformen finden Sie unterHardware- und Softwareanforderungen für die Installation von SQL Server 2005.

Siehe auch

Verweis

Package Class
Package Members
Microsoft.SqlServer.Dts.Runtime Namespace