ConnectionManager.GetExpression(String) Méthode

Définition

Retourne une chaîne qui contient l’expression de la propriété spécifiée. Null signifie qu’aucune expression n’a été affectée.

public:
 virtual System::String ^ GetExpression(System::String ^ propertyName);
public string GetExpression (string propertyName);
abstract member GetExpression : string -> string
override this.GetExpression : string -> string
Public Function GetExpression (propertyName As String) As String

Paramètres

propertyName
String

Nom de la propriété dont vous souhaitez afficher l'expression.

Retours

Chaîne qui contient l’expression utilisée pour évaluer la propriété.

Implémente

Exemples

L’exemple de code suivant définit une expression sur une propriété unique du gestionnaire de connexions, puis la récupère une fois le package validé.

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

namespace ConnMgr_Properties_Collection  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            // The package is one of the SSIS Samples.  
            string mySample = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx";  

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

            // Get the Properties collection from the connection manager.  
            ConnectionManager myConnMgr = myConns[0];  
            DtsProperties connProperties = myConnMgr.Properties;  

            // View information about the RetainSameConnection property   
            // before setting it using the SetExpression method.  
            Boolean hasProperty = connProperties.Contains("RetainSameConnection");  
            Console.WriteLine("has RetainSameConnection? {0}", hasProperty);  
            Object myValue = myConnMgr.Properties["RetainSameConnection"].GetValue(myConnMgr);  
            String mySValue = myValue.ToString();  
            Console.WriteLine("value before is {0}", mySValue);  
            String myTrueString = "true";  

            // Use SetExpression to set the value to true.  
myConnMgr.Properties["RetainSameConnection"].SetExpression(myConnMgr, myTrueString);  

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

            // Now that the value has been set, retrieve the value  
            // and the expression.  
            myValue = myConnMgr.Properties["RetainSameConnection"].GetValue(myConnMgr);  
            mySValue = myValue.ToString();  
            String myExpression = myConnMgr.Properties["RetainSameConnection"].GetExpression(myConnMgr);  
            String mySExpression = myExpression.ToString();  
            Console.WriteLine("value and expression is {0}, {1}", mySValue, mySExpression);   
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace ConnMgr_Properties_Collection  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
        ' The package is one of the SSIS Samples.  
        Dim mySample As String = "C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"  

        ' Create an application and load the sample.  
        Dim app As New Application()  
        Dim pkg As Package = app.LoadPackage(mySample, Nothing)  
        Dim myConns As Connections = pkg.Connections  

        ' Get the Properties collection from the connection manager.  
        Dim myConnMgr As ConnectionManager = myConns(0)  
        Dim connProperties As DtsProperties = myConnMgr.Properties  

        ' View information about the RetainSameConnection property   
        ' before setting it using the SetExpression method.  
        Dim hasProperty As [Boolean] = connProperties.Contains("RetainSameConnection")  
        Console.WriteLine("has RetainSameConnection? {0}", hasProperty)  
        Dim myValue As [Object] = myConnMgr.Properties("RetainSameConnection").GetValue(myConnMgr)  
        Dim mySValue As String = myValue.ToString()  
        Console.WriteLine("value before is {0}", mySValue)  
        Dim myTrueString As String = "true"  

        ' Use SetExpression to set the value to true.  
myConnMgr.Properties("RetainSameConnection").SetExpression(myConnMgr, myTrueString)  

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

        ' Now that the value has been set, retrieve the value  
        ' and the expression.  
        myValue = myConnMgr.Properties("RetainSameConnection").GetValue(myConnMgr)  
        mySValue = myValue.ToString()  
        Dim myExpression As String = myConnMgr.Properties("RetainSameConnection").GetExpression(myConnMgr)  
        Dim mySExpression As String = myExpression.ToString()  
        Console.WriteLine("value and expression is {0}, {1}", mySValue, mySExpression)   
        End Sub  
    End Class  
End Namespace  

Exemple de sortie :

est-ce que RetainSameConnection ? True

valeur antérieure à False

valeur et expression est True, true

Remarques

Il propertyName peut s’agir d’une chaîne de connexion, d’une description, d’un nom ou d’un niveau de protection. Pour le gestionnaire de connexions, il s’agit actuellement des seules propriétés qui prennent en charge les expressions.

Outre ces propriétés courantes du gestionnaire de connexions, chaque type de connexion possède des propriétés uniques. Ces propriétés sont répertoriées par la Properties collection.

S’applique à