DbServerSyncProvider.ApplyChangeFailed 事件

在服务器上应用某行失败后发生。

命名空间: Microsoft.Synchronization.Data.Server
程序集: Microsoft.Synchronization.Data.Server(在 microsoft.synchronization.data.server.dll 中)

语法

声明
Public Event ApplyChangeFailed As EventHandler(Of ApplyChangeFailedEventArgs)
用法
Dim instance As DbServerSyncProvider
Dim handler As EventHandler(Of ApplyChangeFailedEventArgs)

AddHandler instance.ApplyChangeFailed, handler
public event EventHandler<ApplyChangeFailedEventArgs> ApplyChangeFailed
public:
event EventHandler<ApplyChangeFailedEventArgs^>^ ApplyChangeFailed {
    void add (EventHandler<ApplyChangeFailedEventArgs^>^ value);
    void remove (EventHandler<ApplyChangeFailedEventArgs^>^ value);
}
/** @event */
public void add_ApplyChangeFailed (EventHandler<ApplyChangeFailedEventArgs> value)

/** @event */
public void remove_ApplyChangeFailed (EventHandler<ApplyChangeFailedEventArgs> value)
JScript supports the use of events, but not the declaration of new ones.

备注

如果在同步期间无法应用某行,则会引发 ApplyChangeFailed 事件。ApplyChangeFailedEventArgs 对象提供有关导致失败的错误或冲突的信息。在事件处理程序中,可以用多种方式来响应事件,包括指定同步提供程序是否应该重新尝试应用该行。有关更多信息,请参见如何处理事件和对业务逻辑进行编程如何处理数据冲突和错误

示例

下面的代码示例为 ApplyChangeFailed 事件指定事件处理程序。调用的方法可针对客户端和服务器同步提供程序将信息记录到单独的文件中。若要在完整示例上下文中查看此代码,请参见如何使用会话变量

this.ApplyChangeFailed += new EventHandler<ApplyChangeFailedEventArgs>(EventLogger.LogEvents);
else if (e is ApplyChangeFailedEventArgs)
{

    ApplyChangeFailedEventArgs args = (ApplyChangeFailedEventArgs)e;
    outputText.AppendLine("** APPLY CHANGE FAILURE AT " + site.ToUpper() + " **");
    outputText.AppendLine("Table for which failure occurred: " + args.TableMetadata.TableName);
    outputText.AppendLine("Error message: " + args.Error.Message);

}
AddHandler Me.ApplyChangeFailed, AddressOf EventLogger.LogEvents
ElseIf TypeOf e Is ApplyChangeFailedEventArgs Then

    Dim args As ApplyChangeFailedEventArgs = CType(e, ApplyChangeFailedEventArgs)
    outputText.AppendLine("** APPLY CHANGE FAILURE AT " & site.ToUpper() & " **")
    outputText.AppendLine("Table for which failure occurred: " & args.TableMetadata.TableName)
    outputText.AppendLine("Error message: " & args.Error.Message)

请参阅

参考

DbServerSyncProvider 类
DbServerSyncProvider 成员
Microsoft.Synchronization.Data.Server 命名空间