다음을 통해 공유


PipelineComponent.AcquireConnections Method

Establishes a connection to a connection manager.

네임스페이스: Microsoft.SqlServer.Dts.Pipeline
어셈블리: Microsoft.SqlServer.PipelineHost (in microsoft.sqlserver.pipelinehost.dll)

구문

‘선언
Public Overridable Sub AcquireConnections ( _
    transaction As Object _
)
public virtual void AcquireConnections (
    Object transaction
)
public:
virtual void AcquireConnections (
    Object^ transaction
)
public void AcquireConnections (
    Object transaction
)
public function AcquireConnections (
    transaction : Object
)

매개 변수

  • transaction
    The transaction the connection is participating in.

주의

AcquireConnections is called during both component design and execution. Components that connect to external data sources should establish their connections during this method. Any connection established during this method should be cached in a local member variable and released in the ReleaseConnections method. Connections should only be established during AcquireConnections.

The following example shows a component that connects to an ADO.NET connection manager during AcquireConnections.

public override void AcquireConnections(object transaction)
{
    if (ComponentMetaData.RuntimeConnectionCollection[0].ConnectionManager != null)
    {
            // Convert the native IDTSConnectionManager90 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 IDTSConnectionManager90 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

스레드 보안

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 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.

참고 항목

참조

PipelineComponent Class
PipelineComponent Members
Microsoft.SqlServer.Dts.Pipeline Namespace