ConnectionManager.AcquireConnection(Object) 方法

定义

创建连接类型的实例。

public:
 System::Object ^ AcquireConnection(System::Object ^ txn);
public object AcquireConnection (object txn);
member this.AcquireConnection : obj -> obj
Public Function AcquireConnection (txn As Object) As Object

参数

txn
Object

事务类型的句柄。

返回

一个包含事务连接的对象。

示例

下面的代码示例演示如何将 OLE DB 连接添加到连接管理器并获取连接。

// Create the package.  
Package pkg = new Package();  

// Add a ConnectionManager to the Connections collection.  
ConnectionManager connMgr = pkg.Connections.Add("ADO.NET:OLEDB");  
connMgr.Properties["RetainSameConnection"].SetValue(connMgr , true);  
connMgr.ConnectionString = connStr;  

// Aqcuire the connection.  
object connection = connMgr.AcquireConnection(null);  
' Create the package.  
Dim pkg As Package =  New Package()   

' Add a ConnectionManager to the Connections collection.  
Dim connMgr As ConnectionManager =  pkg.Connections.Add("ADO.NET:OLEDB")   
connMgr.Properties("RetainSameConnection").SetValue(connMgr , True)  
connMgr.ConnectionString = connStr  

' Aqcuire the connection.  
Dim connection As Object =  connMgr.AcquireConnection(Nothing)  

注解

null属性为falseSupportsDTCTransactions传递事务参数txnSupportsDTCTransactions如果属性是true,则可以传入null事务参数来指示容器支持事务,但不会参与。

适用于