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!
perfconAsked:
Who is Participating?
 
mdagisCommented:
HI suspect that there is problem reading the snapshot folder.

Go to replication moniton on the server and check you pulication errors. If you see there that there was a file system error then add the following line to your code under: repl.PublisherDatabase = "ITinventory"

repl.AltSnapshotFolder= "YourPath"

YourPath should be a local path ON WINDOWS CE. Then copy the contents of the replication folder into that path. The default replication folder path is C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\repldata

 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.