CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Posts
    7

    VB.NET ActiveX Replication , block of code does not execute

    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

  2. #2
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Re: VB.NET ActiveX Replication , block of code does not execute

    Code:
    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.
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

  3. #3
    Join Date
    Apr 2004
    Posts
    7

    Re: VB.NET ActiveX Replication , block of code does not execute

    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,

  4. #4
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Re: VB.NET ActiveX Replication , block of code does not execute

    Did you notice that I posted a modified function?
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured