共用方式為


LogProviderBase.OpenLog Method

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

命名空間: Microsoft.SqlServer.Dts.Runtime
組件: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

語法

'宣告
Public Overridable Sub OpenLog
public virtual void OpenLog ()
public:
virtual void OpenLog ()
public void OpenLog ()
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

執行緒安全性

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 的硬體和軟體需求>。

請參閱

參考

LogProviderBase Class
LogProviderBase Members
Microsoft.SqlServer.Dts.Runtime Namespace