ネイティブ接続マネージャをマネージ ConnectionManager クラスに変換します。 このメソッドは、CLS に準拠していません。
名前空間: Microsoft.SqlServer.Dts.Runtime
アセンブリ: Microsoft.SqlServer.ManagedDTS (microsoft.sqlserver.manageddts.dll 内)
構文
'宣言
Public Shared Function ToConnectionManager ( _
connMgr90 As IDTSConnectionManager90 _
) As ConnectionManager
public static ConnectionManager ToConnectionManager (
IDTSConnectionManager90 connMgr90
)
public:
static ConnectionManager^ ToConnectionManager (
IDTSConnectionManager90^ connMgr90
)
public static ConnectionManager ToConnectionManager (
IDTSConnectionManager90 connMgr90
)
public static function ToConnectionManager (
connMgr90 : IDTSConnectionManager90
) : ConnectionManager
パラメータ
- connMgr90
ネイティブ接続マネージャです。
戻り値
マネージ ConnectionManager クラスです。
使用例
次のコード例では、AcquireConnections の間、ToConnectionManager を使用して接続をマネージ接続に変換し、ADO.NET 接続マネージャに接続するパイプライン コンポーネントを示します。
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 = cm.InnerObject as 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 = cmado.AcquireConnectionCType(as OleDbConnection, transaction)
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
}
スレッド セーフ
この型の public static (Microsoft Visual Basic では共有 ) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォーム
開発プラットフォーム
サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。
対象プラットフォーム
サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。
参照
関連項目
DtsConvert Class
DtsConvert Members
Microsoft.SqlServer.Dts.Runtime Namespace