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 オブジェクトです。

次のコード サンプルでは、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 データ オブジェクト (ADO) オブジェクトにアクセスするための ADO

  • ADO.NET オブジェクトにアクセスするための ADO.NET

  • ファイルにアクセスするための FILE

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

  • Web サーバーにアクセスするための HTTP

  • OLE DB を使用するリレーショナル データ ソースにアクセスするための OLEDB

  • ODBC を使用するデータベースにアクセスするための ODBC

  • サーバーにアクセスし、サーバーに管理スコープを指定するための Windows Management Instrumentation (WMI)

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

  • Microsoft SQL Server Analysis Services または Analysis Services プロジェクトのインスタンスにアクセスするための MSOLAP100

有効な接続文字列の詳細については、「 Integration Services (SSIS) 接続」を参照してください。

適用対象