locked
Changes not being pushed to server (SQL Server 2008) from WPF Application RRS feed

  • Question

  • Hi Guys,
    Attempting to get a very simple sync system set up to push new records recorded from a WPF with a local database cache to a remote SQL Server.
    I added a local database cache to my project and followed the steps - all seemed good.

    Now, I can add new records to the local database and have verified that they are they but when I sync nothing gets uploaded. Any changes in the master database are getting downloaded however.
    Sorry I can't provide any more information. Im new to this and am not getting any error messages or anything like that.
    is there anything I can do to get some more info as to why this is happening or has anyone got any ideas?

    It may be relevent that I set the set the sync framework to sync around 10 tables, but it only appeared to create SQL scripts to enable change tracking on two of them. Not that those tables are syncing anyway.

    All help REALLY appreciated!

    PS - I am using the entity framework to add the rows to the SQL CE database
    Thursday, May 14, 2009 8:39 AM

Answers

  • http://msdn.microsoft.com/en-us/library/cc761546.aspx

    Looks like by default the configuration dialog sets all tables to download only.
    Either I was being stupid or this wasn't made clear anywhere :-\

    Anyways, hopefully this info will be useful for someone else one day!

    :)
    • Marked as answer by Warpkid Thursday, May 14, 2009 2:12 PM
    Thursday, May 14, 2009 2:12 PM

All replies

  • A little more info.
    I suspected that the problem may have been due to the fact that my tables had a few relations between them and that the changes were being rejected by the server due to foriegn key constaints.
    Im not sure if I did this correctly but I attempted to hook into the applychanegs failed event to see if this was the case using the following code.
    public partial class brandFourDataSyncServerSyncProvider : Microsoft.Synchronization.Data.Server.DbServerSyncProvider
        {
            partial void OnInitialized()
            {
                this.ApplyChangeFailed += new EventHandler<Microsoft.Synchronization.Data.ApplyChangeFailedEventArgs>(brandFourDataSyncServerSyncProvider_ApplyChangeFailed);
            }
    
            void brandFourDataSyncServerSyncProvider_ApplyChangeFailed(object sender, Microsoft.Synchronization.Data.ApplyChangeFailedEventArgs e)
            {
                throw new Exception(e.Conflict.ErrorMessage);
            }
    However, no exception is being thrown.

    All I get from syncstats is that 0 changes were uploaded despite the fact that in my sql ce database (in /bin/debug) there are a bunch of new rows in a few of the tables.

    I dont think I can run SQL Profiler as I dont have direct access to the database server. It is hosted remotly so my only link is through SQL Server Management Studio Express 2008


    Thanks!
    Thursday, May 14, 2009 9:55 AM
  • Ok, so ive looked in the .sync file and examined the code that the wizard produced.
    It would appear that all thetables have the property syncDirection="DownloadOnly"

    <syncTables>
        <syncTable Id="1a4bd7b6-d37a-42fb-85df-4da920a0f970" name="tblActivityQuestionSetsSyncTable" syncDirection="DownloadOnly" creationOptions="DropExistingOrCreateNewTable" tableName="tblActivityQuestionSets" fullTableName="dbo.tblActivityQuestionSets" transactionIndex="0">
          <syncGroup>
            <syncGroupMoniker name="/211ead2c-ea23-4465-be58-7f054b4440a4/tblActivityQuestionSetsSyncGroup" />
          </syncGroup>
        </syncTable>

    My question, why would this be the case? There would appear to be no option in the wizard to set the sync direction one way or another.

    Can I simply alter these properties to bidirectional as I need?

    Thanks
    Thursday, May 14, 2009 12:26 PM
  • http://msdn.microsoft.com/en-us/library/cc761546.aspx

    Looks like by default the configuration dialog sets all tables to download only.
    Either I was being stupid or this wasn't made clear anywhere :-\

    Anyways, hopefully this info will be useful for someone else one day!

    :)
    • Marked as answer by Warpkid Thursday, May 14, 2009 2:12 PM
    Thursday, May 14, 2009 2:12 PM