Sql Server CE 3.5 Merge Replication Synchronization - Hanging

I am using SQL Server 2005 CE framework 3.5 and am trying to use merge replication between my arm and my SQL Server. When I run the code to synchronize, it just seems like it sits forever, and when I put a breakpoint in my code, it never skips a call to Synchronize ().

If I look at the replication monitor on the sql server, it gets to the point where it says the subscription is no longer syncing and shows no errors. So my guess is that it means sync is complete.

http: //server/virtualdirectory/sqlcesa35.dll? diag doesn't report any problems.

This is my first attempt at any pocket development, so I may have done something stupid. However, SQL Server seems to be reporting a successful sync.

Any help would be greatly appreciated as I wasted my time!

Here is my code.

const string DatabasePath = @"SD Card\mydb.sdf";
var repl = new SqlCeReplication
               {
                   ConnectionManager = true,
                   InternetUrl = @"http://server/virtualdirectory/sqlcesa35.dll",
                   Publisher = @"servername",
                   PublisherDatabase = @"databasename",
                   PublisherSecurityMode = SecurityType.DBAuthentication,
                   PublisherLogin = @"username",
                   PublisherPassword = @"password",
                   Publication = @"publicationname",
                   Subscriber = @"PPC",
                   SubscriberConnectionString = "Data Source=" + DatabasePath
               };
try
{
    Cursor.Current = Cursors.WaitCursor;
    if (!File.Exists(DatabasePath))
    {
        repl.AddSubscription(AddOption.CreateDatabase);
    }
    repl.Synchronize();
    MessageBox.Show("Successfully synchronised");
}
catch (SqlCeException e)
{
    DisplaySqlCeErrors(e.Errors, e);
}
finally
{
    repl.Dispose();
    Cursor.Current = Cursors.Default;
}

      

+1


source to share


2 answers


Another thing you can do to speed up the Synchronize operation is to provide the path to the db file that is in the main program memory of your PDA (not on the SD card as in your example) You should see a speed increase of up to 4X (which means Sync can only take 25% if it accepts now).



If your PDA is running out of main program memory, you can use System.IO.File.Move () to move the file to the SD card after calling Synchronize. It seems a little odd, I know, but it's much faster to sync to program memory and copy to SD card and then sync directly to SD card.

+1


source


Since then, I've found that copying data to the physical disk takes quite a long time. Although SQL Server replication was complete, it was still copying data to SD card.

I figured it out by decreasing the number of tables I replicate and got a faster response (well, another error, but not related to this issue).



Thank you anyway:)

0


source







All Articles