Udostępnij za pośrednictwem


Metoda PipelineComponent.AcquireConnections

Ustanawia połączenie menedżer połączeń.

Przestrzeń nazw:  Microsoft.SqlServer.Dts.Pipeline
Zestaw:  Microsoft.SqlServer.PipelineHost (w Microsoft.SqlServer.PipelineHost.dll)

Składnia

'Deklaracja
Public Overridable Sub AcquireConnections ( _
    transaction As Object _
)
'Użycie
Dim instance As PipelineComponent
Dim transaction As Object

instance.AcquireConnections(transaction)
public virtual void AcquireConnections(
    Object transaction
)
public:
virtual void AcquireConnections(
    Object^ transaction
)
abstract AcquireConnections : 
        transaction:Object -> unit 
override AcquireConnections : 
        transaction:Object -> unit 
public function AcquireConnections(
    transaction : Object
)

Parametry

  • transaction
    Typ: System.Object
    Bierze udział w transakcji połączenia.

Uwagi

AcquireConnectionsnazywa się podczas projektowania składników i wykonanie.Składniki połączenia z zewnętrznymi źródłami danych powinna ustanowić połączenia ich podczas tej metoda.Każde połączenie ustanowione podczas tej metoda powinny być buforowane w lokalnym element członkowski zmienna i wydane w ReleaseConnections metoda.Tylko ustanowić połączenia podczas AcquireConnections.

Przykłady

Składnik, który łączy się z obiektów ADO można znaleźć w poniższym przykładzie.Menedżer połączeń netto podczas AcquireConnections.

public override void AcquireConnections(object transaction)
{
    if (ComponentMetaData.RuntimeConnectionCollection[0].ConnectionManager != null)
    {
            // Convert the native IDTSConnectionManager100 to the managed ConnectionManager,
            // then retrieve the underlying connection through the InnerObject.
            ConnectionManager cm = Microsoft.SqlServer.Dts.Runtime.DtsConvert.ToConnectionManager(ComponentMetaData.RuntimeConnectionCollection[0].ConnectionManager);
            ConnectionManagerAdoNet cmado = cm.InnerObject  as ConnectionManagerAdoNet;

            // If the InnerObject is not an ConnectionManagerAdoNet, then
            // the cmado object is null.
            if( cmado == null )
                throw new Exception("The ConnectionManager " + cm.Name + " is not an ADO.NET connection.");

            // Get the underlying connection object.
            this.oledbConnection = cmado.AcquireConnection(transaction) as OleDbConnection;

            if( this.oledbConnection == null )
                throw new Exception("The ConnectionManager " + cm.Name + " is not an ADO.NET connection.");

            isConnected = true;
    }
}
Public Overrides Sub AcquireConnections(ByVal transaction As Object) 
 If Not (ComponentMetaData.RuntimeConnectionCollection(0).ConnectionManager Is Nothing) Then 
   ' Convert the native IDTSConnectionManager100 to the managed ConnectionManager,
   '  then retrieve the underlying connection through the InnerObject.
   Dim cm As ConnectionManager = Microsoft.SqlServer.Dts.Runtime.DtsConvert.ToConnectionManager(ComponentMetaData.RuntimeConnectionCollection(0).ConnectionManager) 
   Dim cmado As ConnectionManagerAdoNet = CType(ConversionHelpers.AsWorkaround(cm.InnerObject, GetType(ConnectionManagerAdoNet)), ConnectionManagerAdoNet) 
   ' If the InnerObject is not an ConnectionManagerAdoNet, then
   '  the cmado object is null.
   If cmado Is Nothing Then 
     Throw New Exception("The ConnectionManager " + cm.Name + " is not an ADO.NET connection.") 
   End If 
   ' Get the underlying connection object.
   Me.oledbConnection = CType(ConversionHelpers.AsWorkaround(cmado.AcquireConnection(transaction), GetType(OleDbConnection)), OleDbConnection) 
   If Me.oledbConnection Is Nothing Then 
     Throw New Exception("The ConnectionManager " + cm.Name + " is not an ADO.NET connection.") 
   End If 
   isConnected = True 
 End If 
End Sub