다음을 통해 공유


OpenLog 메서드

Called at the beginning of package execution to establish connections to external data sources.

네임스페이스:  Microsoft.SqlServer.Dts.Runtime
어셈블리:  Microsoft.SqlServer.ManagedDTS.dll의 Microsoft.SqlServer.ManagedDTS

구문

‘선언
Public Overridable Sub OpenLog
‘사용 방법
Dim instance As LogProviderBase

instance.OpenLog()
public virtual void OpenLog()
public:
virtual void OpenLog()
abstract OpenLog : unit -> unit 
override OpenLog : unit -> unit 
public function OpenLog()

주의

This method is called at the beginning of package execution and prior to any execution events occurring. You should use this method to establish connections to external data sources and prepare to respond to calls to the Log method.

예제

The following example demonstrates connecting to an external text file using the ConnectionManager specified in the ConfigString property. The connection variable was cached from the

InitializeLogProvider method.

public override void OpenLog()
{
    //    Get the ConnectionManager from the package's
    //    Connections collection.
    connectionManager cm = connections[ConfigString];
    //    AcquireConnection for a file ConnectionManager
    //    retrieves the path to the file.
    string path = (string)cm.AcquireConnection(null);
    //    Instantiate the stream writer, and writes the opening
    //    log entry.
    this.sw = new StreamWriter(path);
    sw.WriteLine("OpenLog: " + DateTime.Now.ToShortDateString());
}
Public Overrides  Sub OpenLog()
    '    Get the ConnectionManager from the package's
    '    Connections collection.
    Dim cm As connectionManager =  connections(ConfigString) 
    '    AcquireConnection for a file ConnectionManager
    '    retrieves the path to the file.
    Dim path As String = CType(cm.AcquireConnection(Nothing), String)
    '    Instantiate the stream writer, and writes the opening
    '    log entry.
    Me.sw = New StreamWriter(path)
    sw.WriteLine("OpenLog: " + DateTime.Now.ToShortDateString())
End Sub