Wednesday, August 08, 2012 11:33 AM
I have created an application which synchronize the records in the local .sdf database through local database cache with the sql server database. Synchronization process working in a well and good condition.
In that application i have come across with an issue that, the data's in the local database does nt suppose to update in the server database while sync. Further i proceed the procedure explained in the below link
By Following this procedure, I have error in my application at the ApplyChangeFailed event of the server.
Please guide me to overcome from this issue.
Also is there any possibility to use the client table in the local database without any primary key.
Thanks & Regards,
Friday, August 10, 2012 6:16 AMModerator
you might want to post exactly what error you're getting?
also, are you saying your application is not able to update the server? or you dont want your application to update the server?
Tuesday, August 14, 2012 4:55 AM
The records in the local database updated onto the server only when i use the seperate database in the server as a localdatacache(DemoDB.sdf) in my application. If i create a new smart device application with the localdatacache(i.e. Same database as used in my previous application - DemoDB.sdf) , when i going to synchronize the records, it throw an exception as "Target Invocation Exception". If i use the different database i.e "SampleDB.sdf" , synchronization works fine.
My Question is,
1. Is there any possibility to use the database(DemoDB.sdf) as a localdatacache also as localdatabase for several times in different smart device application.?
2. How to use the tables in a database without any primary keys (i.e For my application duplication is not an issue)
3. Want to know the Standard database and table framework for the synchronization processes.
Thanks and Regards,
Tuesday, August 14, 2012 5:14 AMModerator
when you copy the SDF, do you sync it against the same server database?
Sync Framework needs a PK, if an update happens on a row in the source, how does it know which row to update on the server without a PK?
Tuesday, August 14, 2012 8:52 AM
Yes thanks, Sync framework needs a PK.
Is it possible to copy the .sdf in one application and use it in another smart device application ? When i do the same, it throw an error that "Source file for this operation cannot be found on the solution". Please guide me and tell me the procedure how to copy and use the .sdf file in different application.
Thanks and Regards.
Tuesday, August 14, 2012 10:34 AMModerator
yes you can. but am not sure your error has something to do with sync fx itself, it seems to me a visual studio project/solution issue.
can you post the actualy error?
Tuesday, August 14, 2012 11:24 AM
When i going to copy the .sdf(i.e DemoDB.sdf) file and paste it into my same application. It works and sync successfully. But it does not happen in another new application. It throw a message as "Source file for this operation cannot be found on the solution". But the DemoDB.sdf file is added as "DemoDB.sdf1" in my new application when i drag and drop the .sdf file from the previous application to the solution explorer. But the problem is that it does not make any synchronization.
And also i want to know whether we use the same database(i.e DemoDB.sdf) in any other synchronization process which is already used for one synchronization application?
Because am not able to use the same database for multiple synchronization process!
Tuesday, August 14, 2012 11:44 AMModerator
as i have mentioned, your error has nothing to do with sync framework.
Tuesday, August 14, 2012 12:07 PM
Yes I have added the .sdf file in my application from another application by your usefull reply as a link.
I have here added the sample coding for my sync process in the button click event of the windows form. Here I used the DemoDB.sdf as a local database cache.
Here the script,
private void menuItem1_Click(object sender, EventArgs e)
1. Cursor.Current = Cursors.WaitCursor;
// The WCF Service
2. WebReference.LocalDataCache1SyncService webSvcProxy = new TestApplication03.WebReference.LocalDataCache1SyncService();
// The Remote Server Provider Proxy
3. Microsoft.Synchronization.Data.ServerSyncProviderProxy serverProvider = new
// The Sync Agent
4. LocalDataCache1SyncAgent syncAgent = new LocalDataCache1SyncAgent();
5. syncAgent.RemoteProvider = serverProvider;
6. syncAgent.LT_LAEMI_MT_CellZone.SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Bidirectional;
// Synchronize the databases
7. Microsoft.Synchronization.Data.SyncStatistics stats = syncAgent.Synchronize();
// Reload the DataSet/Datagrid from the local database
// Show synchronization statistics
8. MessageBox.Show("Changes Downloaded: " + stats.TotalChangesDownloaded.ToString() +
"\r\n" + "Changes Uploaded: " + stats.TotalChangesUploaded.ToString());
9. Cursor.Current = Cursors.Default;
When iam going to click the button for sync, it throw an "Target invocation exception" at the Line 7.
Thats why i have asked you that, whether it is possible to use the same database in any other synchronization process which is used already in one sync application?. This is the issue that iam facing currently.
Tuesday, August 14, 2012 12:20 PMModerator
as i have mentioned, yes, you can reuse the database.
the Target Invocation error you're getting is most likely to do with WCF. I suggest you enable detailed WCF exception and enable tracing to get the more detailed inner exception.
- Marked As Answer by Sukash Thursday, August 16, 2012 5:18 AM
Tuesday, August 14, 2012 12:31 PM
Thanks for your Message. I thought the problem with the same database usage. Because when i use the different database it didnt show the error, Works fine. Now the content is clear. I will check and confirm the WCF exception and trace the inner exception and revert you back with the positive reply.
Thanks and regards
Thursday, August 16, 2012 5:17 AM
Finally my issue is fixed now. I traced and clear the WCF exception. Its working now properly.
Thanks and Regards,