Connections.Add(String) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Fügt der Sammlung ein ConnectionManager Objekt des angegebenen Verbindungstyps Connections hinzu.
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
Parameter
- connectionType
- String
Dieser Parameter gibt den Verbindungstyp an. Zum Beispiel gibt die Zeichenkette "FILE" einen Verbindungsmanager für Dateien an.
Gibt zurück
Das neue ConnectionManager Objekt, das der Connections Sammlung hinzugefügt wurde.
Beispiele
Das folgende Codebeispiel fügt einem Paket, das zwei bestehende Verbindungen enthält, einen ADO.NET-Verbindungsmanager hinzu.
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
Beispielausgabe:
The number of connections is: 2
The number of connections now is: 3
Hinweise
Der für den connectionType Parameter in dieser Methode verwendete Wert ist der, der in der Property-Linie ConnectionManagerType im Designer angezeigt wird. SQL Server (SSIS) umfasst mehrere gängige Verbindungstypen, darunter die folgenden Verbindungsmanagertypen:
ADO zum Zugriff auf Microsoft ActiveX Data Objects (ADO)-Objekte
ADO.NET zum Zugriff auf ADONET-Objekte
FILE zum Zugriff auf Dateien
FLATFILE zum Zugriff auf Daten in Flatfiles
HTTP zum Zugriff auf einen Webserver
OLEDB zum Zugriff auf relationale Datenquellen mittels OLE DB
ODBC zum Zugriff auf Datenbanken mit ODBC
Windows Management Instrumentation (WMI) zum Zugriff auf einen Server und zur Festlegung des Verwaltungsumfangs auf dem Server
FTP zum Zugriff auf einen Server, um Dateien zu senden und zu empfangen
MSOLAP100 für den Zugriff auf eine Microsoft SQL Server Analysis Services-Instanz oder ein Analysis Services-Projekt
Weitere Informationen zu den gültigen Verbindungstyp-Zeichenketten finden Sie unter Integration Services (SSIS) Connections.