CodeSmith Community
Your Code. Your Way. Faster!

Sync between two same structure databases using the same Entities and Data components - on different machines

Latest post 05-07-2008 8:18 AM by evolved. 5 replies.
  • 08-21-2007 7:55 AM

    • alex_b
    • Not Ranked
    • Joined on 08-16-2007
    • Farnborough, UK
    • Posts 4
    • Points 50

    Sync between two same structure databases using the same Entities and Data components - on different machines

    Hi all,

    I am new to nettiers and am loving it.  I may be asking a question that is/has been handled elsewhere but I have been unable to find it.

    I have a master database called ALIS with a generated data access layer that works great.  I have a system where I need to have a laptop/pda that is only intermittently connected to the LAN on which the master database resides.  What I need to do is when using the laptop I need to have access to a copy of the records in the master in disconnected mode - I thought that I could simply use a copy of the database on the laptop.  When I connect I can sync the records programatically.  I was thinking that the best method for implementation was to use two nettiers providers, one looking at the master and one looking at the local copy.

    Given that the access to the data is via the DataRepository.<mytype>.GetAll...... how can I set up my configuration to use one or the other database?  The database names and tables are the same, only the connection string will be different.  The providers are stored in a collection, however is it only the default that ever gets used?

    I am putting off the obvious solution of using another storage mechanism on the laptop such as XML because with reuse I only need to configure the different connection strings.

    any help appreciated, 

    Alex

    Latest test includes using multiple providers in the config, using different connection strings - then accessing them using:

    DataRepository.Providers["SqlNetTiersProvider"].MyProvider.getAll() and DataRepository.Providers["SqlNetTiersProvider2"].MyProvider.getAll()
     

    ----------------------------------------------------------------- adding value
    • Post Points: 35
  • 08-21-2007 9:40 AM In reply to

    • evolved
    • Top 50 Contributor
    • Joined on 12-27-2004
    • South River, NJ
    • Posts 93
    • Points 1,825

    Re: Sync between two same structure databases using the same Entities and Data components - on different machines

    This is 'bigger than nettiers' question really, but I have done similar work so I can try to help.

     I ended up using SQL Server CE, which is a file based in-process database kind of like firebird. I always talked to the local database on the semi-connected device, and when there was a connection to the full db available I had a windows service that would 'replicate' the data to-from the db. Full replication in my situation was not possible due to the fact that the target DB might have not been a full copy of SQL Server. It was a lot of work, but it ended up working. Thank god I used guid's for the ID's in the beginning of the project, otherwise with all these devices i would have had key conflicts left and right.

     

    HTH
     

    http://www.jheidt.com
    ------------------------------
    Member of the .NetTiers team
    http://www.nettiers.com
    ------------------------------

    • Post Points: 35
  • 05-06-2008 11:10 AM In reply to

    • gordonj
    • Top 200 Contributor
    • Joined on 03-26-2008
    • Posts 24
    • Points 490

    Re: Sync between two same structure databases using the same Entities and Data components - on different machines

    I am looking to attempt a similar project where I intend to view a local SQL Server CE ans sync when online.

    Is there any sample code available for this?

    I intent to have a web site on a number of laptops which can sync back to the server through the Nettiers web service (hopefully). 

    The main sync examples seem to use dataadapters and it would be great to see an example of how to alter this to use NetTiers so that I don't have to create a parrallel data cennection that runs outwith the great work of nettiers.

    • Post Points: 35
  • 05-06-2008 11:54 AM In reply to

    • evolved
    • Top 50 Contributor
    • Joined on 12-27-2004
    • South River, NJ
    • Posts 93
    • Points 1,825

    Re: Sync between two same structure databases using the same Entities and Data components - on different machines

    There is tons of example code available on the SQL CE forums of people home-brewing replication. And there is a new SQL command MERGE which is right down this alley. The key (pun intended) is to avoid collisions, and make sure you schema is sound, changing schema is a nightmare once you have some type of replication mechanism setup.

    Out of curiousity, why would you use 'a website on laptops', it seems really silly (no offense meant) if you have the full power of a local laptop, why would you tie yourself down in IIS?

    http://www.jheidt.com
    ------------------------------
    Member of the .NetTiers team
    http://www.nettiers.com
    ------------------------------

    • Post Points: 35
  • 05-07-2008 3:48 AM In reply to

    • gordonj
    • Top 200 Contributor
    • Joined on 03-26-2008
    • Posts 24
    • Points 490

    Re: Sync between two same structure databases using the same Entities and Data components - on different machines

    The project I am attempting has fairly complex data so I thought that for rapid development I could use the web on the laptops.  It seemed like a good idea as, if neccessary, I could quickly put together a Windows Service to handle the sync.

     In the future, the client might want to go down a Windows Forms route.

     I suppose the client and I are most comfortable with web pages which can be relatively simple to change compared with windows form applications.

    I will look at the SQL CE forums and the Merge command.

    Thanks for your pointers.

    • Post Points: 35
  • 05-07-2008 8:18 AM In reply to

    • evolved
    • Top 50 Contributor
    • Joined on 12-27-2004
    • South River, NJ
    • Posts 93
    • Points 1,825

    Re: Sync between two same structure databases using the same Entities and Data components - on different machines

    Sure, no problem. Another interesting development in this area is the Microsoft Sync Framework, which is in beta right now but available on MSDN, that is intended to suit this type of need directly.

     

     

    http://www.jheidt.com
    ------------------------------
    Member of the .NetTiers team
    http://www.nettiers.com
    ------------------------------

    • Post Points: 5
Page 1 of 1 (6 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems