I have received many question on how to automatically start synchronization between the device and desktop when using ADS, hence i am posting this blog which outlines “one” way to do this.
“For automatically initiating a sync your application on the device would have to wait for the Active Sync connection event and initiate the sync once this event happens. Note that the sync is always initiated from the device, you cannot initiate from the desktop. This solution works using RDA components on the device. For RDA programming you can read SSCE books online. We are providing a sample application along with source code. This shows how to sync the databases. This sample does not demonstrate “automatic” syncing, but implementing that should be quite straight forward in your application. There can be several ways of doing this
One way is : On desktop “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\AutoStartOnConnect – Here you can specify any action to take when ActiveSync connection is established. Similarly for disconnection key is “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\AutoStartOnDisconnect”. You can write a small app which uses RAPI function call to start your sync app on the device as well as load the ADS desktop component. You can specify this appplication to be executed when active sync connection is established by adding an entry under the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\AutoStartOnConnect. There can be many different ways of architecting/designing your application based on your requirement”
Manish Agnihotri, Program Manager, SQL Server 2005 Compact Edition
Please post all SQL Server 2005 Compact Edition queries at http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=152&SiteID=1