locked
Is Peer-to-Peer Sync between SQL Compact 2008 (sdf) databases possible? RRS feed

  • Question

  • I would like to synchronize two SQL Compact 2008 (sdf) files, but WITHOUT the need to go through SQL Server Express.

    My customers want to be able to share the data they collect individually (while away from the network) but installing and configuring SQL Server Express is too much for them.

    Thank you.

    Thomas
    • Moved by Max Wang_1983 Thursday, April 21, 2011 10:42 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Friday, October 30, 2009 1:35 PM

Answers

  • Hi,

    You can use the SqlCeSyncProvider to sync two SQLCeProviders directly. The steps are:

    1. use Provisioning API to construct a DbSyncScopeDescription instance
    2. Apply this DbSyncScopeDescription to the two SQL CE databases
    3. Create SqlCeSyncProvider instances for the two SQL CE db and sync

    Please take a look the sample "Database Sync: SQL Server and SQL Server Compact" in http://code.msdn.microsoft.com/sync. You can create more than one SqlCeSyncProvider in this sample and sync them direclty.

    Thanks,
    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    • Proposed as answer by Dong CaoMicrosoft employee, Moderator Friday, October 30, 2009 4:46 PM
    • Marked as answer by TomHN Friday, October 30, 2009 7:49 PM
    • Unmarked as answer by TomHN Monday, November 2, 2009 3:25 PM
    • Marked as answer by TomHN Friday, November 6, 2009 12:36 PM
    Friday, October 30, 2009 4:46 PM
    Moderator

All replies

  • Hi,

    You can use the SqlCeSyncProvider to sync two SQLCeProviders directly. The steps are:

    1. use Provisioning API to construct a DbSyncScopeDescription instance
    2. Apply this DbSyncScopeDescription to the two SQL CE databases
    3. Create SqlCeSyncProvider instances for the two SQL CE db and sync

    Please take a look the sample "Database Sync: SQL Server and SQL Server Compact" in http://code.msdn.microsoft.com/sync. You can create more than one SqlCeSyncProvider in this sample and sync them direclty.

    Thanks,
    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    • Proposed as answer by Dong CaoMicrosoft employee, Moderator Friday, October 30, 2009 4:46 PM
    • Marked as answer by TomHN Friday, October 30, 2009 7:49 PM
    • Unmarked as answer by TomHN Monday, November 2, 2009 3:25 PM
    • Marked as answer by TomHN Friday, November 6, 2009 12:36 PM
    Friday, October 30, 2009 4:46 PM
    Moderator
  • Hi Dong,

    From the documentation (Architecture and Classes for Collaborative Synchronization):

    "If you are synchronizing two SQL Server Compact databases by using two instances of SqlCeSyncProvider , you must use an n-tier architecture. Two-tier architectures are not supported for this scenario."

    Doesn't this mean that you can _NOT_ "create more than one SqlCeSyncProvider in this sample and sync them directly"?

    Or are the three steps you wrote for an n-tier architecture?

    I'm not sure because you don't mention a Proxy on the local computer, or a Service of the remote computer. From the documentation, both of these seem to be required (and both must be written by the developer.)

    Thanks again.

    Thomas

    Monday, November 2, 2009 3:24 PM
  • Hi Thomas,

    This note seems not very clear to me. I guess that it is intended to mean that for 2 SqlCe databases on two different machines, you need to use n-tier architecture since you cannot connect to SQLCe store with a remote connection string.

    If two SqlCe databases are on the same machine, the steps I listed in my previous reply should work. The code sample works in this way actually. Please try it.

    Thanks,
    Dong
    This posting is provided AS IS with no warranties, and confers no rights.
    Tuesday, November 3, 2009 1:34 AM
    Moderator
  • Hi Dong,

    Yes, the two SqlCe databases are on two different machines.

    But I'm not sure what you mean by "you cannot connect to SQLCe store with a remote connection string". If I have the sdf file is on the server, all users can indeed connect it from any computer on our network - just not at the same time. (Is this not what you meant by "remote connection"?)

    Therefore, if the two SqlCe databases are NOT on the same machine, but ARE on the same local network, will the steps you listed work?

    If not, do you know of a code sample that shows P2P syncing between SqlCe databases using an n-tier architecture?

    Once again, many thanks.

    Thomas
    Tuesday, November 3, 2009 12:01 PM
  • Hi Thomas,

    You mean access the remote SQLCE database file on a remote share. It will work too. In this case, the SQLCE database file is like a local file. The only limitation is that SQLCE only allows one active connection to the database file on the remote share.

    Thanks,
    Dong 


    This posting is provided AS IS with no warranties, and confers no rights.
    • Marked as answer by TomHN Friday, November 6, 2009 12:35 PM
    • Unmarked as answer by TomHN Friday, November 6, 2009 12:36 PM
    Tuesday, November 3, 2009 6:06 PM
    Moderator
  • Thanks very much, Dong. I tried it, and it does indeed work.

    Thomas
    Friday, November 6, 2009 12:38 PM