Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge and synchronize SQL Server Database Files?

I'm building a C# program for windows tablets that are synchronized with a database. They will each have their own local .MDF SQL Server database which they interact with using SQL Server Express.

However the users will take the tablets out of an internet connection and make changes. Then when one reconnects to the network which contains a "master copy" of the DataBase, I want to synchronize their .MDF database with that. Then replace the database files of the computer and the tablet with the newly synchronized one.

I have a uniqueidentifier column, and a datetime of when that row was last changed, so if there were conflicts I'd just take the most recent change.

I've read some literature on this, but I'd love to see an explicit example or tutorial of how to do it. I know what I want is Merge Replication, and that Microsoft Sync Framework seems to have the functionality I want. I just am struggling to implement it. Alternatively, feel free to recommend a different tool to do it.

Thanks in advance!

like image 959
Charles Clayton Avatar asked Mar 09 '15 20:03

Charles Clayton


2 Answers

I know this isn't much of an answer but I'm sure this is done with Microsoft Sync Framework. I'm also quite sure you can easily sync a db from a tablet even though it was offline. The only limitation could be the lack of live sync for which you'd need to use Azure services, WebSockets, Apache MQ or whatever. Apologies for lack of more info, I'd post it as a comment but don't have enough points.

like image 137
bokibeg Avatar answered Oct 11 '22 19:10

bokibeg


if it's a Windows Store App (WinRT), you have to use the Sync Framework Toolkit .

if plain Windows app (WPF, WinForms, etc...), yes, you can use Sync Framework.

the idea for both is that your Windows app uses a local database (SQL CE, LocalDB, SQLite, etc...) for CRUD that you occasionally sync with a central server when you have connection (via WCF, like this)

like image 30
JuneT Avatar answered Oct 11 '22 19:10

JuneT