Metoda LogProviderBase.OpenLog
Nazywa się na początku wykonanie pakiet do ustanawiania połączeń z zewnętrznymi źródłami danych.
Przestrzeń nazw: Microsoft.SqlServer.Dts.Runtime
Zestaw: Microsoft.SqlServer.ManagedDTS (w Microsoft.SqlServer.ManagedDTS.dll)
Składnia
'Deklaracja
Public Overridable Sub OpenLog
'Użycie
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()
Uwagi
Metoda ta jest wywoływana na początku wykonanie pakiet i przed występowaniu zdarzeń wykonanie.Tej metoda należy używać do ustanawiania połączeń z zewnętrznymi źródłami danych i przygotować odpowiedzieć na wywołania Log metoda.
Przykłady
Poniższy przykład ilustruje połączyć plik tekstowy za pomocą ConnectionManager określonych w ConfigString właściwość.Zmienna połączenia została buforowana z
InitializeLogProviderMetoda.
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