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
        End If
    End Sub

    Sub SynchronizeSubscription()
            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;"
            Catch err As SqlCeException
                MessageBox.Show(err.ToString + err.StackTrace)
            End Try
        End Try

Any help will be greatly appreciated. Thanks!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.