locked
I cant Sync SQL Server on Windows Phone 7, Here's my code. Please help!! RRS feed

  • Question

  • Hi,

     

    I'm using the Microsoft Sync Framework 4.0 and have generated the service from the SvcUtilHelper and added it to the server. Here's the code

     

     

     

    public class UserSyncSyncService : Microsoft.Synchronization.Services.SyncService<UserSyncOfflineEntities> {
            
            public static void InitializeService(Microsoft.Synchronization.Services.ISyncServiceConfiguration config) {
                // TODO: MUST set these values
                 config.ServerConnectionString = @NutriLeaf.Services.Constants.Settings.ServerDbConnectionString;
                 config.SetEnableScope("UserSync");
                // 
                // 
                // TODO: Optional.
                config.SetDefaultSyncSerializationFormat(Microsoft.Synchronization.Services.SyncSerializationFormat.ODataJson);
                //config.SetConflictResolutionPolicy(Microsoft.Synchronization.Services.ConflictResolutionPolicy.ClientWins);
                config.EnableDiagnosticPage = true;
                config.UseVerboseErrors = true;
                config.AddFilterParameterConfiguration("UserID", "Users", "@UserID", typeof(int));
    
                config.AddFilterParameterConfiguration("UserID", "UserProfiles", "@UserProfileID", typeof(int));
            }
        }
    


     

     

    and have also included the cross domain acccess xml file. Viewed the diagnostic page with all test PASSED!

     

    Client :

     

    Here's the code on my phone 7 : Generated the DataContext from the Utility again!

     public static void SyncUser()
            {
                if (setting.User.UserID == 0 || setting.User.UserID == null)
                {
                    return;
                }
    
                
                context.CacheController.ControllerBehavior.AddScopeParameters("UserID", setting.User.UserID.ToString());
                context.CacheController.ControllerBehavior.SerializationFormat = Microsoft.Synchronization.ClientServices.SerializationFormat.ODataJSON;
                context.LoadCompleted += new EventHandler<Microsoft.Synchronization.ClientServices.IsolatedStorage.LoadCompletedEventArgs>(context_LoadCompleted);
                context.LoadAsync();
            }
    
            static void context_LoadCompleted(object sender, Microsoft.Synchronization.ClientServices.IsolatedStorage.LoadCompletedEventArgs e)
            {
                context.UsersCollection.Single(); //ERROR - Sequence contains no elements
                EventHandler completed = UserSyncCompleted;
                if (completed != null)
                {
                    completed(UserSyncCompleted, EventArgs.Empty);
                }
            }
    


     

    I know, I have a single element on the server. Why cant I get that down to my client??

     

    Please Help!! 

     


    Nawaz Dhandala
    Monday, November 7, 2011 5:50 PM

All replies

  • does this happen on first sync? or subsequent sync?

    try running SQL Profiler and see what select query it's firing and see if it's actually returning rows.

    Tuesday, November 8, 2011 2:53 AM