Search code examples
c#iphoneobjective-csqliteasihttprequest

iPhone Synchronizing SQLite with Windows Server Database


Background information:

I have been building an App that allows users to interact with each other, post comments/images for the App etc and these all information gets displayed on my App's FanWall screen. I am getting users information using their FaceBook authentication through FBConnect.

To update fanwall screen efficiently, I want to have a local SQLite database for my App that contains userId, his profile image, his comments for my App etc. I have all these info in my SQL server database but not sure how to synchronize this info with iPhone's SQLite database.

My problems:

I am using ASIHTTPRequest to query my SQL database and it can return whole table as Array of C# .NET class. The things that I couldn't understand is;

  1. how to parse this C# .NET class using Objective-c to fetch each class object that is corresponds to each row.
  2. I can then update my local SQLite using this object information but what could be best way to update only rows that are changed? Ideally I should be able to get only required rows from SQL server Database so that I just need to insert them in SQLite. I saw this post but not much helpful for my problem. Just wondering if there is any tool out there that can do this synchronization? I can have tables exactly same on SQL Server and SQLite.

Please let me know your thought on this.

Thanks.


Solution

  • I'm working on a similar problem. How to keep in sync a remote database with a local database. Either end could add or update rows. The solution seems to be to keep a column in each table called lastModifiedDate. This column is set on the server so there will be uniform time.

    Periodically, connect to the server and request all rows greater than your local lastModifedDate to get updates and adds. Also, when you push your local changes to the server, the server should modify the lastModifiedDate for uniformity.

    I haven't seen a framework for something like this.