ConnectionManager.Name 屬性

定義

取得或設定物件名稱 ConnectionManager

public:
 property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
[Microsoft.SqlServer.Dts.Runtime.Localization.LocalizablePropertyDescription(typeof(Microsoft.SqlServer.Dts.Runtime.Localized), "NameDesc")]
public string Name { get; set; }
[<Microsoft.SqlServer.Dts.Runtime.Localization.LocalizablePropertyDescription(typeof(Microsoft.SqlServer.Dts.Runtime.Localized), "NameDesc")>]
member this.Name : string with get, set
Public Property Name As String

屬性值

一個包含你在建立連線管理器物件時給它的名稱的字串。

實作

屬性

範例

以下程式碼範例載入一個已有的套件,該套件有兩個連接。 它會遍歷套件中的連接管理器,並列印出各種屬性的值,包括 Name

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

namespace Connections_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;  
            int connCount = myConns.Count;  
            Console.WriteLine("The number of connections in the package is: {0}", connCount);  

            // Enumerate over the collection, printing out  
            // the values for various properties.  
            foreach (ConnectionManager connMgr in myConns)  
            {  
                Console.WriteLine("ConnectionString:        {0}", connMgr.ConnectionString);  
                Console.WriteLine("CreationName:            {0}", connMgr.CreationName);  
                Console.WriteLine("DelayValidation:         {0}", connMgr.DelayValidation);  
                Console.WriteLine("Description:             {0}", connMgr.Description);  
                Console.WriteLine("HostType:                {0}", connMgr.HostType);  
                Console.WriteLine("ID:                      {0}", connMgr.ID);  
                Console.WriteLine("InnerObject:             {0}", connMgr.InnerObject);  
                Console.WriteLine("Name:                    {0}", connMgr.Name);  
                Console.WriteLine("ProtectionLevel:         {0}", connMgr.ProtectionLevel);  
                Console.WriteLine("SupportsDTCTransactions: {0}", connMgr.SupportsDTCTransactions);  
            }  
            Console.WriteLine("");  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace Connections_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   
            Dim connCount As Integer =  myConns.Count   
            Console.WriteLine("The number of connections in the package is: {0}", connCount)  

            ' Enumerate over the collection, printing out  
            ' the values for various properties.  
            Dim connMgr As ConnectionManager  
            For Each connMgr In myConns  
                Console.WriteLine("ConnectionString:        {0}", connMgr.ConnectionString)  
                Console.WriteLine("CreationName:            {0}", connMgr.CreationName)  
                Console.WriteLine("DelayValidation:         {0}", connMgr.DelayValidation)  
                Console.WriteLine("Description:             {0}", connMgr.Description)  
                Console.WriteLine("HostType:                {0}", connMgr.HostType)  
                Console.WriteLine("ID:                      {0}", connMgr.ID)  
                Console.WriteLine("InnerObject:             {0}", connMgr.InnerObject)  
                Console.WriteLine("Name:                    {0}", connMgr.Name)  
                Console.WriteLine("ProtectionLevel:         {0}", connMgr.ProtectionLevel)  
                Console.WriteLine("SupportsDTCTransactions: {0}", connMgr.SupportsDTCTransactions)  
            Next  

            Console.WriteLine("")  
        End Sub  
    End Class  
End Namespace  

範例輸出:

封裝中的連接數為:2

ConnectionString:資料來源=localhost;初始目錄=AdventureWorks;Provider=SQLOLEDB.1;整合安全=SSPI;持續執行安全資訊=False;自動翻譯=錯誤;

創世名稱:OLEDB

延遲驗證:錯誤

描述:

HostType:ConnectionManager

編號:{3427BFE1-F10C-4B7E-8E70-E8D9DC7DDBA3}

內在物件:System.__ComObject

名稱:localhost。冒險作品

保護等級:EncryptSensitiveWithUserKey

支援DTCT行動:正確

ConnectionString:C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\results.txt

創世名稱:FLATFILE

延遲驗證:錯誤

描述:

HostType:ConnectionManager

編號:{48B66F8D-7DFE-4D85-91C7-0999655484B2}

內在物件:System.__ComObject

名稱:依 Product1 交易摘要

保護等級:EncryptSensitiveWithUserKey

支援DTCT行動:錯誤

備註

這是連線管理器建立時所命名的名稱,之後可以修改。 在圖形使用者介面中,名稱會以名稱屬性的形式出現在 連線管理員 編輯器或屬性清單中。 若連線建立時未指派名稱,執行時會指派為 。ID

適用於