Message event

The Message event is triggered when dbmlsync logs information.

Syntax
Public Event Message(_
  ByVal msgClass As DbmlsyncCOM.MessageClass, _
  ByVal msgID As Integer, ByVal msg As String_
)
Member of DbmlsyncCOM.Dbmlsync
Parameters

msgClass   indicates the severity of the message. Values can be:

  • MsgInfo   A message containing progress information about the synchronization.

  • MsgDetailedInfo   Like MsgInfo, but containing more detailed information.

  • MsgWarning   A message indicating a potential problem but one that does not prevent successful synchronization.

  • MsgError   A message indicating a problem that prevents successful synchronization.

msgID   A unique identifier for the message. If msgID is zero, the message does not have a unique identifier.

msg   The text of the message.

Remarks

Use this event to receive information logged by dbmlsync. If you want to add special processing when a specific message is generated, check for it by MsgID. That way, your code continues to work if the text of the message changes.

Example

The following Visual Basic .NET example adds messages logged by dbmlsync to a listbox control.

Private Sub dbmlsync1_Message(
 ByVal msgClass As DbmlsyncCOM.MessageClass,
 ByVal msgId As Integer, ByVal msg As String
)
Handles dbmlsync1.Message
    
    Select Case msgClass
        Case DbmlsyncCOM.MessageClass.MsgError
            lstMessages.Items.Add("Error: " + msg)
        Case DbmlsyncCOM.MessageClass.MsgWarning
            lstMessages.Items.Add("Warning: " + msg)
        Case DbmlsyncCOM.MessageClass.MsgInfo
            lstMessages.Items.Add("Info: " + msg)
        Case DbmlsyncCOM.MessageClass.MsgDetailedInfo
            lstMessages.Items.Add("DetInfo: " + msg)
    End Select

End Sub
Example

The following Visual Basic .NET example sets up the Message event to handle errors. Error messages are added to a ListBox control called lstMessages.

Private Sub dbmlsync1_Message(ByVal msgClass As DbmlsyncCOM.MessageClass, ByVal msgId As Integer, ByVal msg As String) Handles dbmlsync1.Message
  If msgClass = DbmlsyncCOM.MessageClass.MsgError Then
   lstMessages.Items.Add("Error: " + msgId.ToString() + " " + msg)
  End If
End Sub

To see possible error id values, test run the Dbmlsync integration component. For example, if dbmlsync returns the error "Unable to connect to MobiLink server", the Message event inserts the following entry in lstMessages:

Error: 14173 Unable to connect to MobiLink server.

Now, you can associate the error "Unable to connect to MobiLink server" with the error id 14173. The following example sets up the Dbmlsync integration component to retry a synchronization whenever error 14173 occurs. The Message event sets a variable called restartSynchronization and resets a variable called numberOfRestarts in response to error 14173. The EndSynchronization event retries the synchronization up to five times.

' variables for restarting synchronization
Dim numberOfRestarts As Integer = 0
Dim restartSynchronization As Integer = 0



Private Sub dbmlsync1_Message
(
 ByVal msgClass As DbmlsyncCOM.MessageClass,
 ByVal msgId As Integer, ByVal msg As String ) Handles dbmlsync1.Message
    
 If msgClass = DbmlsyncCOM.MessageClass.MsgError Then
     lstMessages.Items.Add("Error: " + msgId.ToString() + " " + msg)

     If msgId = 14173 Then
       restartSynchronization = 1
       numberOfRestarts = 0
     End If
 End If
End Sub

Private Sub dbmlsync1_EndSynchronization(ByVal ExitCode As Integer, _
    ByRef restart As Boolean _
    ) Handles dbmlsync1.EndSynchronization
    

    If restartSynchronization = 1 Then
      If numberOfRestarts < 5 Then
         restart = True
         numberOfRestarts = numberOfRestarts + 1
      End If
    End If
End Sub