Connections.Add(String) 메서드

정의

ConnectionManager 컬렉션에 지정한 연결 유형의 Connections 개체를 추가합니다.

public:
 Microsoft::SqlServer::Dts::Runtime::ConnectionManager ^ Add(System::String ^ connectionType);
public Microsoft.SqlServer.Dts.Runtime.ConnectionManager Add (string connectionType);
member this.Add : string -> Microsoft.SqlServer.Dts.Runtime.ConnectionManager
Public Function Add (connectionType As String) As ConnectionManager

매개 변수

connectionType
String

이 매개 변수는 연결 유형을 지정합니다. 예를 들어 "FILE"은 파일에 대한 연결 관리자를 지정하는 문자열입니다.

반환

ConnectionManager 컬렉션에 추가된 새 Connections 개체입니다.

예제

다음 코드 샘플에서는 두 개의 기존 연결이 포함된 패키지에 ADO.NET 연결 관리자를 추가합니다.

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

namespace ConnMgr_GetEnum_Current  
{  
    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);  

            // Get the Connections collection from the package.  
            Connections conns = pkg.Connections;  

            // Count the number of connections in the package.  
            int myConns = conns.Count;  
            Console.WriteLine("The number of connections is: {0}", myConns);  

            //Add a new connection manager to the collection.  
            conns.Add("ADO.NET");  
            myConns = conns.Count;  
            Console.WriteLine("The number of connections now is: {0}", myConns);  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace ConnMgr_GetEnum_Current  
    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)   

            ' Get the Connections collection from the package.  
            Dim conns As Connections =  pkg.Connections   

            ' Count the number of connections in the package.  
            Dim myConns As Integer =  conns.Count   
            Console.WriteLine("The number of connections is: {0}", myConns)  

            'Add a new connection manager to the collection.  
            conns.Add("ADO.NET")  
            myConns = conns.Count  
            Console.WriteLine("The number of connections now is: {0}", myConns)  
        End Sub  
    End Class  
End Namespace  

샘플 출력:

The number of connections is: 2

The number of connections now is: 3

설명

이 메서드의 connectionType 매개 변수에 사용되는 값은 Designer의 ConnectionManagerType 속성에 표시되는 값입니다. SSIS(SQL Server)에는 다음과 같은 연결 관리자 유형을 포함하여 몇 가지 일반적인 연결 형식이 포함됩니다.

  • Microsoft ADO(ActiveX Data Objects) 개체에 액세스하기 위한 ADO

  • ADO.NET 개체에 액세스하기 위한 ADO.NET

  • 파일에 액세스하기 위한 FILE

  • 플랫 파일의 데이터에 액세스하기 위한 FLATFILE

  • 웹 서버에 액세스하기 위한 HTTP

  • OLE DB를 사용하여 관계형 데이터 원본에 액세스하기 위한 OLEDB

  • ODBC를 사용하여 데이터베이스에 액세스하기 위한 ODBC

  • 서버에 액세스하고 서버에서 관리 범위를 지정하기 위한 WMI(Windows Management Instrumentation)

  • 파일을 보내고 받기 위해 서버에 액세스하기 위한 FTP

  • Microsoft SQL Server Analysis Services 또는 Analysis Services 프로젝트의 인스턴스에 액세스하기 위한 MSOLAP100

유효한 연결 형식 문자열에 대한 자세한 내용은 Integration Services(SSIS) 연결을 참조하세요.

적용 대상