Link to home
Start Free TrialLog in
Avatar of perfcon
perfcon

asked on

Synchronization issue between SQL Server 2005 and SQL CE databases (using VB.NET in VS 2005)

I have been trying to make a mobile application.

I am using VS 2005 with Sp2 (Professional Edition)
SQL Server 2005 (Developer Edition)
SQL Server CE 3

I have created a small database in SQL Server 2005 and a small CE database. To sync both databases, I can understand that In I need merge replication. So I have created a publication and then a subscription with the .sdf file. I did perform web synchronization with my publication.

My question is: In my application I am trying to synchronize my local sdf file. The code I am using was generated when I have created subscription. I made small changes as mentioned in msdn.

When I deploy my application in my device (connected to my PC through usb) the application runs fine but WITHOUT synchronizing and giving me NO ERROR! I need help in this regard.

I was trying to use the same code to synchronize my server database with the changes made in CE database at the end of saving data in local dataset. In this case I just use the same sub in the edit data page but removed a line of code and that is: "repl.AddSubscription(AddOption.ExistingDatabase)"

But my CE database is not synchronized after the changes I made. But I can synchronize subscription from Management Studio with no issue.

I need help as I am newbie working on my first application. The pieces of code,I used is given below for reviews/suggestions:



Dim filename As String = "\Program Files\PCI_Scanner\ITinventoryProject.sdf"

Sub DeleteDB()
        If System.IO.File.Exists(filename) Then
            System.IO.File.Delete(filename)
        End If
    End Sub

    Sub SynchronizeSubscription()
        Try
            Dim repl As New SqlCeReplication()

            repl.InternetUrl = "http://PCI1835/ITinventory/sqlcesa30.dll"
            repl.Publisher = "PCI1835"
            repl.PublisherDatabase = "ITinventory"
            repl.PublisherSecurityMode = SecurityType.NTAuthentication
            repl.Publication = "ITINVENTORY"
            repl.Subscriber = "ITINVENTORY"
            repl.SubscriberConnectionString = "Data Source=""\Program Files\PCI_Scanner\ITinventoryProject.sdf"";Max Database Size=128;Default Lock Escalation =100;"
            Try
                repl.AddSubscription(AddOption.ExistingDatabase)
                repl.Synchronize()
            Catch err As SqlCeException
                MessageBox.Show(err.ToString + err.StackTrace)
            End Try
        Catch
        Finally  
        End Try


Any help will be greatly appreciated. Thanks!
ASKER CERTIFIED SOLUTION
Avatar of mdagis
mdagis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial