Click to See Complete Forum and Search --> : VB.NET ActiveX Replication , block of code does not execute


veasnamuch
September 1st, 2004, 12:57 AM
I need to write an application in VB.NET to syncronize data in between 2
server.
I have implement a Merge Replication in between this 2 servers. After I run
the applicaton as code describe over here, I got syncronized data in
this 2 servers. But The Statusbar and Status message of executing does not
work. I have run step by step executing but the procedure myMergeObj_Status
is never get in.

Could you tell me how can I solve this problem?


Thanks for your helps,




Imports SQLMERGXLib
Imports REPLERRXLib

Public Class MainForm
Inherits System.Windows.Forms.Form

Private WithEvents myMergeObj As New SQLMerge()
Private myReplErr As New SQLReplError()
Private strMessage As String
Private blnCancel As Boolean

Private Sub SyncronizeSreverReplication()
cmdSync.Enabled = False
blnCancel = False
cmdCancel.Enabled = True
cmdClose.Enabled = False

With myMergeObj
.Publisher = txtPublisherServer.Text
.PublisherDatabase = txtPublicationDB.Text
.Publication = txtPublicationName.Text
.PublisherSecurityMode = SECURITY_TYPE.NT_AUTHENTICATION

.Subscriber = txtSubscriberServer.Text
.SubscriberDatabase = txtSubscriptionDB.Text
.SubscriberSecurityMode = SECURITY_TYPE.NT_AUTHENTICATION
.SubscriptionType = SUBSCRIPTION_TYPE.ANONYMOUS
End With

Try
myMergeObj.Initialize()
myMergeObj.Run()
myMergeObj.Terminate()
MsgBox("Update is complete - " & strMessage)
BarSyncProgress.Value = 0
Catch ex As Exception
Dim errString As String

If myMergeObj.ErrorRecords.Count > 0 Then
For Each myReplErr In myMergeObj.ErrorRecords
errString = errString & vbCrLf & myReplErr.Description
Next
MsgBox("The following replication error(s) occurred:" & vbCrLf &
errString)
Else
MsgBox("The following system exception has occurred:" & vbCrLf &
ex.ToString())
End If
Finally
cmdSync.Enabled = True
cmdCancel.Enabled = False
cmdClose.Enabled = True
BarSyncProgress.Value = 0
End Try

End Sub

Private Sub cmdSync_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSync.Click

AddHandler myMergeObj.Status, New
_SQLMergeEvents_StatusEventHandler(AddressOf myMergeObj_Status)

Call Me.SyncronizeSreverReplication()
End Sub

Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdClose.Click

MyBase.Close()
End Sub


'This block of code is never execute
'***********************************************
Private Sub myMergeObj_Status(ByVal message As String, _
ByVal percent As Integer, _
ByRef retCode As STATUS_RETURN_CODE) _
Handles myMergeObj.Status

Me.lblStatus.Text = message
Me.BarSyncProgress.Value = percent
If blnCancel Then retCode = STATUS_RETURN_CODE.CANCEL
strMessage = message
Application.DoEvents()
End Sub'***********************************************

Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCancel.Click

blnCancel = True
End Sub

End Class

Craig Gemmill
September 1st, 2004, 01:35 AM
Private Function mobjMerge_Status(ByVal Message As String, _
ByVal Percent As Integer) As STATUS_RETURN_CODE
...

Return STATUS_RETURN_CODE.Cancel 'Or whatever status



I also remember seeing something about need W2k/SP3 (if you are running W2k that is) for this to function correctly, although I may be wrong.

veasnamuch
September 6th, 2004, 03:18 AM
I have updated my Windows 2000 to the service pack 3 but still see nothing happend.

Could u tell me how could I do next?


Best regards,

Craig Gemmill
September 6th, 2004, 09:51 AM
Did you notice that I posted a modified function?