RelationalSyncProvider.DbConnectionFailure Event

Occurs when the database connection fails during change application.

Namespace:  Microsoft.Synchronization.Data
Assembly:  Microsoft.Synchronization.Data (in Microsoft.Synchronization.Data.dll)

Syntax

'Declaration
Public Event DbConnectionFailure As EventHandler(Of DbConnectionFailureEventArgs)
'Usage
Dim instance As RelationalSyncProvider
Dim handler As EventHandler(Of DbConnectionFailureEventArgs)

AddHandler instance.DbConnectionFailure, handler
public event EventHandler<DbConnectionFailureEventArgs> DbConnectionFailure
public:
 event EventHandler<DbConnectionFailureEventArgs^>^ DbConnectionFailure {
    void add (EventHandler<DbConnectionFailureEventArgs^>^ value);
    void remove (EventHandler<DbConnectionFailureEventArgs^>^ value);
}
member DbConnectionFailure : IEvent<EventHandler<DbConnectionFailureEventArgs>,
    DbConnectionFailureEventArgs>
JScript supports the use of events, but not the declaration of new ones.

Remarks

This event can be used to override the default action taken when a database connection is throttled on a shared system, such as SQL Azure. The synchronization application can register to handle this event and can decide whether to retry the transaction or cancel synchronization.

Examples

The following example shows the DbConnectionFailure event handler. This event handler checks the number of retry attempts and overrides the default to retry the change application 10 times before stopping synchronization.

static void HandleDbConnectionFailure(object sender, DbConnectionFailureEventArgs e)
{
    // Override the default to retry 10 times before fail.
    if (e.RetryCount < 10)
    {
        e.Action = DbConnectionFailureAction.RetrySync;
    }
    else
    {
        e.Action = DbConnectionFailureAction.AbortSync;
    }
}
Private Shared Sub HandleDbConnectionFailure(ByVal sender As Object, ByVal e As DbConnectionFailureEventArgs)
    ' Override the default to retry 10 times before fail.
    If e.RetryCount < 10 Then
        e.Action = DbConnectionFailureAction.RetrySync
    Else
        e.Action = DbConnectionFailureAction.AbortSync
    End If
End Sub

See Also

Reference

RelationalSyncProvider Class

Microsoft.Synchronization.Data Namespace

Other Resources

How to: Configure and Execute Synchronization with SQL Azure