ConnectionManager.SetExpression(String, String) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 표현식을 속성에 할당합니다. null을 지정하여 속성에서 기존 표현식을 제거하세요.
public:
virtual void SetExpression(System::String ^ propertyName, System::String ^ expression);
public void SetExpression(string propertyName, string expression);
abstract member SetExpression : string * string -> unit
override this.SetExpression : string * string -> unit
Public Sub SetExpression (propertyName As String, expression As String)
매개 변수
- propertyName
- String
표현식을 할당할 속성의 이름입니다.
- expression
- String
식입니다.
구현
예제
다음 코드 예시는 연결 관리자에 특화된 속성의 값을 지정하는 표현식을 사용하는 방법을 보여줍니다. 연결 관리자에 고유한 속성들이 컬렉션에 Properties 포함되어 있습니다.
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 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 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
샘플 출력:
RetainSameConnection이 있나요? True
값은 거짓입니다
다음 값은 참이다
설명
connection manager 객체는 propertyName 연결 문자열, description, name, 보호 수준일 수 있습니다. 연결 관리자의 경우, 현재 표현식을 지원하는 속성은 이 기능들뿐입니다. 이러한 일반적인 연결 관리자 속성 외에도, 각 연결 유형은 고유한 속성을 가지고 있습니다. 이 부동산들은 소장품별로 Properties 나열되어 있습니다. 메서드를 SetExpression 사용해 속성 이름을 매개변수로 String 지정할 수 있습니다. 만약 이 컬렉션을 사용하여 Properties 연결에 고유한 속성을 설정하고 싶다면, 이 속성 컬렉션이 로부터 DtsProperty상속받는다는 점을 아는 것이 유용할 수 있습니다. 상속된 것은 DtsProperty 첫 번째 매개변수String가 아니라 a Object 를 가진다는 점에 주목 SetExpression 하세요.