言語

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」という文字列はファイルの接続マネージャーを指定します。

返品

Connectionsコレクションに追加された新しいConnectionManagerオブジェクト。

以下のコードサンプルは、既存の2つの接続を含むパッケージに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 パラメータに使われる値は、デザイナーの ConnectionManagerType プロパティに示されている値です。 SQL Server(SSIS)には、以下の接続管理タイプを含むいくつかの一般的な接続タイプが含まれています。

  • Microsoft ActiveX Data Objects(ADO)オブジェクトへのアクセスのためのADO

  • ADO.NETオブジェクトへのアクセスにはADO.NET

  • ファイルへのアクセス用ファイル

  • フラットファイル内のデータにアクセスするためのFLATFILE

  • WebサーバーへのアクセスのためのHTTPです

  • OLE DBを用いたリレーショナルデータソースへのアクセスのためのOLEDB

  • ODBCを用いたデータベースアクセスのためのODBC

  • サーバーへのアクセスおよびサーバー上の管理範囲を指定するためのWindows管理計器(WMI)

  • ファイルを送受信するためのサーバーへのアクセスのためのFTP

  • Microsoft SQL Server Analysis ServicesのインスタンスやAnalysis ServicesプロジェクトへのアクセスのためのMSOLAP100

有効な接続タイプ文字列の詳細については、 統合サービス(SSIS)接続を参照してください。

適用対象