ConnectionManager.Properties 属性

定义

获取 ConnectionManager 的属性对象集合。 此方法用于访问连接管理器所承载的特定连接的属性。 此属性为只读。

public:
 property Microsoft::SqlServer::Dts::Runtime::DtsProperties ^ Properties { Microsoft::SqlServer::Dts::Runtime::DtsProperties ^ get(); };
public Microsoft.SqlServer.Dts.Runtime.DtsProperties Properties { get; }
member this.Properties : Microsoft.SqlServer.Dts.Runtime.DtsProperties
Public ReadOnly Property Properties As DtsProperties

属性值

一个 DtsProperties 集合,其中包含特定于该连接类型的属性。

实现

示例

下面的代码示例使用索引语法[0]从集合中的Connections第一个连接管理器获取Properties集合。 然后,该示例将写入集合中找到 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 and iterate through the properties,   
            // printing the property names.  
            ConnectionManager myConnMgr = myConns[0];  
            DtsProperties connProperties = myConnMgr.Properties;  

            foreach (DtsProperty connProp in connProperties)  
                Console.WriteLine(connProp.Name);  
        }  
    }  
}  
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 Application =  New Application()   
            Dim pkg As Package =  app.LoadPackage(mySample,Nothing)   
            Dim myConns As Connections =  pkg.Connections   

            ' Get the Properties collection from the connection  
            ' manager and iterate through the properties,   
            ' printing the property names.  
            Dim myConnMgr As ConnectionManager =  myConns(0)   
            Dim connProperties As DtsProperties =  myConnMgr.Properties   

            Dim connProp As DtsProperty  
            For Each connProp In connProperties  
                Console.WriteLine(connProp.Name)  
            Next  
        End Sub  
    End Class  
End Namespace  

示例输出:

ConnectionString

CreationName

说明

ID

InitialCatalog

名称

密码

ProtectionLevel

RetainSameConnection

ServerName

SupportsDTCTransactions

UserName

注解

ConnectionManager 继承的所有类都包含相同的属性和方法。 但是,每个连接类型具有该连接类型特有的其他属性。 从集合获取连接管理器并循环访问属性时,类中 ConnectionManager 未找到的所有属性都是特定于该连接的属性。 若要设置对连接唯一的属性,但不属于该 ConnectionManager属性(如 RetainSameConnection 在多个连接上找到的属性),请使用以下代码行:

ConnectionManager.Properties("RetainSameConnection") = True

有关可用连接类型的详细信息,请参阅 Integration Services (SSIS) 连接

适用于