다음을 통해 공유


ScriptObjectModel.Transaction Property

Returns the transaction associated with the container of the Script task.

네임스페이스: Microsoft.SqlServer.Dts.Tasks.ScriptTask
어셈블리: Microsoft.SqlServer.ScriptTask (in microsoft.sqlserver.scripttask.dll)

구문

‘선언
Public ReadOnly Property Transaction As Object
public Object Transaction { get; }
public:
property Object^ Transaction {
    Object^ get ();
}
/** @property */
public Object get_Transaction ()
public function get Transaction () : Object

속성 값

The transaction associated with the container of the Script task. This value can be null.

주의

Use the Transaction property of the Dts object in Script task code to reference the transaction associated with the container of the Script task. You may want to pass this transaction reference when calling the AcquireConnection method of a connection manager.

The following sample of code for use inside a Script task demonstrates how to access connection managers from within the Script task and to associate those connections with the active transaction by using the Transaction property. The sample assumes that you have created and configured an ADO.NET connection manager named Test ADO.NET Connection and a Flat File connection manager named Test Flat File Connection. Note that the ADO.NET connection manager returns a SqlConnection object that you can use immediately to connect to the data source. The Flat File connection manager, on the other hand, returns only a string that contains the path and filename. You must use methods from the System.IO namespace to open and work with the flat file.

Public Sub Main()

    Dim myADONETConnection As SqlClient.SqlConnection
    myADONETConnection = _
        DirectCast(Dts.Connections("Test ADO.NET Connection").AcquireConnection(Dts.Transaction), _
        SqlClient.SqlConnection)
    MsgBox(myADONETConnection.ConnectionString, _
        MsgBoxStyle.Information, "ADO.NET Connection")

    Dim myFlatFileConnection As String
    myFlatFileConnection = _
        DirectCast(Dts.Connections("Test Flat File Connection").AcquireConnection(Dts.Transaction), _
        String)
    MsgBox(myFlatFileConnection, MsgBoxStyle.Information, "Flat File Connection")

    Dts.TaskResult = Dts.Results.Success

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

참고 항목

참조

ScriptObjectModel Class
ScriptObjectModel Members
Microsoft.SqlServer.Dts.Tasks.ScriptTask Namespace