LogProvider.GetExpression Method

Returns a String that contains the expression for the specified property. Null means no expression is assigned.

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

public string GetExpression (
	string propertyName
public final String GetExpression (
	String propertyName
public final function GetExpression (
	propertyName : String
) : String



The name of the property whose expression you want to see.

Return Value

A String that contains the expression used to evaluate the property.

The propertyName will be ConfigString, Description, or Name. For the log provider, those are currently the only three properties that can use an expression.

The following example sets the Description property of the log provider to be the text, "This is the log for…" with the current month and day appended to the end of the string. It then validates the package, which resolves the expression and saves the value to the property specified in propertyName. The expression will also be set on the expressions on the property when the package is saved.

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

namespace LogProvider_Expression_Tests
    class Program
        static void Main(string[] args)
            // The package is one of the SSIS Samples. The package was
            // modified to log to the SSIS log provider for Text files
            // and saved before loading into this code.

            string mySample = @"C:\Program Files\Microsoft SQL Server\90\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";

            // Create the Application, and load the sample.
            Application app = new Application();
            Package pkg = app.LoadPackage(mySample, null);

            // Get the LogProviders collection.
            LogProviders logProvs = pkg.LogProviders;

            // Get the "SSIS log provider for Text files"
            // provider from the collection.
            LogProvider textLogProv = logProvs["SSIS log provider for Text files"];

            //Display the current description of this provider.
            String currDescription = textLogProv.Description;
            Console.WriteLine("Current description: {0}", currDescription);

            // Set an expression. Only a few properties
            // are available to have expressions. For Log Providers, 
            //current only the properties of ConfigString, Description,
            // and Name take expressions.
            DateTime dt = DateTime.Now;
            String nowMonth = dt.ToString("m");
            String newDesc = "\"This is the log for " + nowMonth + "\"";
            textLogProv.SetExpression("Description", newDesc);

            // Validate the package to set the expression
            // onto the property.
            Connections pkgConns = pkg.Connections;          
            DTSExecResult valResult = pkg.Validate(pkgConns, null, null, null);
            if (valResult != DTSExecResult.Failure)
                Console.WriteLine("Validation passed: {0}", valResult);
                Console.WriteLine("Validation FAILED: {0}", valResult);

            // Retrieve the log provider collections.
            logProvs = pkg.LogProviders;

            // Retreive the text log provider from the collection.
            textLogProv = logProvs["SSIS log provider for Text files"];

            // Check the expression, and verify that the name changed.
            String logProvExpr = textLogProv.GetExpression("Description");
            Console.WriteLine("The expression for Description is {0}", logProvExpr);
            String newDescAfter = textLogProv.Description;
            Console.WriteLine("The description is now: {0}", newDescAfter);

Sample output:

Current description: Writes log entries for events to a CSV file

Validation passed: Success

The expression for Description is "This is the log for January 06"

The description is now: This is the log for January 06

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.

Development Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

Target Platforms

Community Additions