AcquireConnection 方法
Creates an instance of the connection type.
命名空間: Microsoft.SqlServer.Dts.Runtime
組件: Microsoft.SqlServer.ManagedDTS (在 Microsoft.SqlServer.ManagedDTS.dll 中)
語法
'宣告
Public Function AcquireConnection ( _
txn As Object _
) As Object
'用途
Dim instance As ConnectionManager
Dim txn As Object
Dim returnValue As Object
returnValue = instance.AcquireConnection(txn)
public Object AcquireConnection(
Object txn
)
public:
Object^ AcquireConnection(
Object^ txn
)
member AcquireConnection :
txn:Object -> Object
public function AcquireConnection(
txn : Object
) : Object
參數
- txn
型別:System. . :: . .Object
The handle to a transaction type.
傳回值
型別:System. . :: . .Object
An object that contains the transaction connection.
備註
Pass null Nothing nullptr unit null 參考 (在 Visual Basic 中為 Nothing) for the transaction parameter txn when the SupportsDTCTransactions property is false. If the SupportsDTCTransactions property is true, you can pass null Nothing nullptr unit null 參考 (在 Visual Basic 中為 Nothing) in the transaction parameter to indicate that the container supports transactions, but is not going to participate.
範例
The following code example shows how to add the OLE DB connection to the connection manager and acquire the connection.
// 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)