اقرأ باللغة الإنجليزية

مشاركة عبر


ConnectionManager.AcquireConnection(Object) Method

Definition

Creates an instance of the connection type.

C#
public object AcquireConnection(object txn);

Parameters

txn
Object

The handle to a transaction type.

Returns

An object that contains the transaction connection.

Examples

The following code example shows how to add the OLE DB connection to the connection manager and acquire the connection.

C#
// 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);  

Remarks

Pass null for the transaction parameter txn when the SupportsDTCTransactions property is false. If the SupportsDTCTransactions property is true, you can pass null in the transaction parameter to indicate that the container supports transactions, but is not going to participate.

Applies to

منتج الإصدارات
SQL Server .NET SDK 2016, 2017, 2019