다음을 통해 공유


Connections.Add Method

Adds a ConnectionManager object of the specified connection type to the Connections collection.

네임스페이스: Microsoft.SqlServer.Dts.Runtime
어셈블리: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

구문

‘선언
Public Function Add ( _
    connectionType As String _
) As ConnectionManager
public ConnectionManager Add (
    string connectionType
)
public:
ConnectionManager^ Add (
    String^ connectionType
)
public ConnectionManager Add (
    String connectionType
)
public function Add (
    connectionType : String
) : ConnectionManager

매개 변수

  • connectionType
    This parameter specifies the connection type. For example, the string "FILE" specifies a connection manager for files.

반환 값

The new ConnectionManager object that was added to the Connections collection.

주의

업데이트된 텍스트:2005년 12월 5일

The value used for the connectionType parameter in this method is the value that is shown in the ConnectionManagerType property in the Designer. SQL Server (SSIS) includes several common connection types, including the following connection manager types:

  • ADO for accessing Microsoft ActiveX Data Objects (ADO) objects

  • ADO.NET for accessing ADO.NET objects

  • FILE for accessing files

  • FLATFILE for accessing data in flat files

  • HTTP for accessing a Web server

  • OLEDB for accessing relational data sources using OLE DB

  • ODBC for accessing databases using ODBC

  • Windows Management Instrumentation (WMI) for accessing a server and specifying the scope of management on the server

  • FTP for accessing a server to send and receive files

  • MSOLAP90 for accessing an instance of Microsoft SQL Server 2005 Analysis Services or an Analysis Services project

For more information about the valid connection type strings, see 연결 관리자.

The following code sample adds an ADO.NET connection manager to a package that contains two existing connections.

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\90\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\90\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

Sample Output:

The number of connections is: 2

The number of connections now is: 3

스레드 보안

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

플랫폼

개발 플랫폼

지원되는 플랫폼 목록은 SQL Server 2005 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.

대상 플랫폼

지원되는 플랫폼 목록은 SQL Server 2005 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.

참고 항목

참조

Connections Class
Connections Members
Microsoft.SqlServer.Dts.Runtime Namespace