DtsProperty.SetExpression(Object, String) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Weist dem Objekt den angegebenen Ausdruck zu. Geben Sie null an, um einen vorhandenen Ausdruck aus der Eigenschaft zu entfernen.
public:
void SetExpression(System::Object ^ o, System::String ^ expression);
public void SetExpression (object o, string expression);
member this.SetExpression : obj * string -> unit
Public Sub SetExpression (o As Object, expression As String)
Parameter
- o
- Object
Der Name des Objekts, dem der Ausdruck zugewiesen werden soll.
- expression
- String
Der Ausdruck.
Beispiele
Dies ConnectionManager ist eine Klasse, die von IDTSPropertiesProvider der SetExpression Methode erbt und implementiert. Das folgende Codebeispiel zeigt, wie die SetExpression-Methode verwendet wird. Der Ausdruck legt den Wert einer Eigenschaft fest, die für einen Verbindungs-Manager spezifisch ist. Die Eigenschaften, die für den Verbindungs-Manager eindeutig sind, sind in der Properties-Auflistung enthalten.
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 onto the property.
DTSExecResult valResult = pkg.Validate(myConns, null, null, null);
// Now that the value has been set, retrieve it.
myValue = myConnMgr.Properties["RetainSameConnection"].GetValue(myConnMgr);
mySValue = myValue.ToString();
Console.WriteLine("value after is {0}", mySValue);
}
}
}
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 onto the property.
Dim valResult As DTSExecResult = pkg.Validate(myConns, Nothing, Nothing, Nothing)
' Now that the value has been set, retrieve it.
myValue = myConnMgr.Properties("RetainSameConnection").GetValue(myConnMgr)
mySValue = myValue.ToString()
Console.WriteLine("value after is {0}", mySValue)
End Sub
End Class
End Namespace
Beispielausgabe:
has RetainSameConnection? True
value before is False
value after is True
Hinweise
Alle Container und mehrere zusätzliche Objekte erben von IDTSPropertiesProviderder Schnittstelle, die die GetExpression Und-Methoden SetExpression bereitstellt.