views:

48

answers:

1

Hi evry1, i 've a local database running in iphone app loaded from sqlite....now i need to sync the local db with the database on the server if the user wishes to do so..can any one help me with this....

Thanks in advance!!

A: 

You can use the new ODBC SDK for iOS that lets you connect to a remote ODBC ROUTER where you have your database's Window ODBC driver installed. Then you can make standard ODBC calls to send SELECT, INSERT, UPDATE, DELETE and CALL type queries to your database server.

If you're doing "synchronization", then you'll want to add a "tsClientUpdated" and/or "tsServerUpdated" column to each table you want to keep in sync (tip: use a DEFAULT VALUE and UPDATE TRIGGER on the server database, if it supports them, to auto-set tsServerUpdated). Then just keep track of the DATETIME that your client last synchronized the tables and when it's time to do a sync, selecting row from the tables on the client with more recent tsClientUpdated and compare them to the server and/or select rows on the server with tsServerUpdated values and compare them with the client, adjusting the tsClientUpdated and tsServerUpdated values each time you merge a client and server row together.

AugSoft Tom