locked
bidirectional sync not working RRS feed

  • Question

  •  

    First let me apologize if I offended anyone with my previous post.  I have been working on this for over a month now on trying to get the synchronization working within my application with some success.  Though it is not fully working yet.

     

    My application is based on the syncservices sample for use in SQLExpress.  I need to sync this way since I am using stored procedures and views in my database.

     

     

     I did try the code as mentioned in my previous post for the recent bug fix but it did not work since it is for other than bidirectional.  As far as my application goes, all I did was add a table to the sample databases and then replaced all occurences within the application code and stored procedures for the "orders" table and columns with my table and columns.  I commented out the occurences of the "orders_details" table so that it is not used.  I added my table to the anchor table.  For instance since there was a syncadapter for the orders table, one for the client and one for the server, I replace "orders" with "mytablename".  I thoroughly checked all replacement locations including the column names and column types. 

    I then am able to insert into my client table from the button on the form.  When I press the synchronize button the application syncs my server table with the client table.  I then switch to the datagridview on the form for the server.  I press the insert button and a record gets inserted into my server table.  I then press the synchronize button and nothing happens, no error and no synced data in my client table.  I have debugged and stepped through and it appears to step through everything as it should.  Right now I am stumped.  So any and all suggestions are welcome.

    • Moved by Max Wang_1983 Friday, April 22, 2011 6:40 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Thursday, August 7, 2008 3:43 PM

Answers

  •  

    Thanks, for your input.  A co-worker was able to figure out the problem.  Evidentally one of the values in the queries was set to null instead of zero.  As soon as I can I'll post what the exact solution was.

     

    Thanks,

     

    Trey

    Friday, August 8, 2008 1:54 PM

All replies

  •  

    Hi Tren,

    Without looking at your sample there is no accurate way of me predicting whats wrong with your sample. Here are some steps that I will suggesst you check again.

     

    1. The new table is added to both Server.SyncAdapter collection and Client.SyncTable collection.

    2. Important: Make sure all queries on the SyncAdapter's (both server and client) have the correct stored procs and commands. Double check you are not missing any parameters if any.

    3. Make sure you have an entry for the new table in your anchor table

     

    If all of above are verified then put a break point in SqlExpressClientSyncProvider.cs:GetChanges and ApplyChanges method. Check to see if these break points are hit when you synchronize. If they are hit then it means that the changes are being enumerated and sent to either side.

     

    Also I would hook up Sql profiler to see if any of the queries are failing.

     

    If you want please attach your sample code and we will try to repro it locally.

     

    Thursday, August 7, 2008 9:49 PM
    Moderator
  • Hello Tren,

     

    Since you are using SQL Express, can you turn on SQL profiler to capture TSQL on both Server and Client?

    If we see TSQL but with failed execution, we probably can see if TSQL is correctly generated or the TSQL is not working for your DB/table.

    If TSQL is not generated, then it also showes a signal.

     

    Can you tell what happends on the SQL profiler?

     

    Thanks,

    Friday, August 8, 2008 4:55 AM
    Answerer
  •  

    Thanks, for your input.  A co-worker was able to figure out the problem.  Evidentally one of the values in the queries was set to null instead of zero.  As soon as I can I'll post what the exact solution was.

     

    Thanks,

     

    Trey

    Friday, August 8, 2008 1:54 PM
  •  

       // update row command
     SqlCommand client_updXXXCmd =  new SqlCommand();
       client_updXXXCmd.CommandType = CommandType.StoredProcedure;
       client_updXXXCmd.CommandText = "usp_XXX_applyupdate";
       client_updXXXCmd.Parameters.Add("@XXXID", SqlDbType.NVarChar, 10);

       client_updXXXCmd.Parameters.Add("@XXXName", SqlDbType.NVarChar, 20);
       client_updXXXCmd.Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.Binary, 8);    
       client_updXXXCmd.Parameters.Add("@" + SyncSession.SyncRowCount, SqlDbType.Int).Direction = ParameterDirection.Output;

       client_adapterXXX.UpdateCommand = client_delCardCmd;

     

    ------------------------------------------------------------------------------------------------

     

    Server 服务器端调用 server  usp_XXX_applyupdate"  is server @SyncSession.SyncLastReceivedAnchor  正确

     

     

    Client 客户端调用 client  usp_XXX_applyupdate"   get  a server @SyncSession.SyncLastReceivedAnchor  错误

     

     

      

     

     

     

     

    Saturday, August 9, 2008 10:25 AM