locked
Cannot Upload Changes to Server-Demo III Using Web Service RRS feed

  • Question

  • Hello,

    I am using the code and approach followed in Demo III to synch db between my mobile device using SQL CE 3.5 and SQL server 2005 within the VS 2005 environment. I have only table and I am using bi-directional synchronization. I can get the changes from server onto the client but any inserts or updates that I make on client, are not uploaded on the server. The table has date_created and date_edited columns that I am using to track the updates and therefore I have not included them in the SDF. Here is the code I am using...Any help is highly appreciated.

    Thanks

    Apurva

      _serverProvider = new DbServerSyncProvider();
     SqlConnection serverConnection = new SqlConnection();
                serverConnection.ConnectionString = ConnString;

                _serverProvider.Connection = serverConnection;

      SqlCommand anchorCmd = new SqlCommand();
                anchorCmd.CommandType = CommandType.Text;
                anchorCmd.CommandText = "Select @" + SyncSession.SyncNewReceivedAnchor + " = GETUTCDATE()";  // for SQL Server 2005 SP2, use "min_active_rowversion() - 1"
                anchorCmd.Parameters.Add("@" + SyncSession.SyncNewReceivedAnchor, SqlDbType.DateTime).Direction = ParameterDirection.Output;

                _serverProvider.SelectNewAnchorCommand = anchorCmd;

                SyncAdapter adaptorInventory = new SyncAdapter("InventoryTest");

      // incremental inserts command
                SqlCommand incInsInventoryCmd = new SqlCommand();
                incInsInventoryCmd.CommandType = CommandType.Text;


    incInsInventoryCmd.CommandText = "select INV_ID, GPA_ID, label,Tier1_ID, Tier2_ID, Tier3_ID, Tier4_ID, FeatureType, Active, user_created, user_edited from [InventoryTest] " +
                                                         " where date_created > @sync_last_received_anchor " +
                                                           "and date_created <= @sync_new_received_anchor " +
                                                           "order by date_created desc ";

      incInsInventoryCmd.Parameters.Add("@" + SyncSession.SyncClientIdHash, SqlDbType.Int);
                incInsInventoryCmd.Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.DateTime);
                incInsInventoryCmd.Parameters.Add("@" + SyncSession.SyncNewReceivedAnchor, SqlDbType.DateTime);

              

                adaptorInventory.SelectIncrementalInsertsCommand = incInsInventoryCmd;



     SqlCommand insInventoryCmd = new SqlCommand();
                insInventoryCmd.CommandType = CommandType.Text;
          
                insInventoryCmd.CommandText = "INSERT INTO InventoryTest (INV_ID, GPA_ID, label,Tier1_ID, Tier2_ID, Tier3_ID, Tier4_ID, FeatureType, Active, user_created, user_edited, update_originator_id) VALUES (@INV_ID, @GPA_ID, @label,@Tier1_ID, @Tier2_ID, @Tier3_ID, @Tier4_ID, @FeatureType, @Active, @user_created, @user_edited, @sync_client_id_hash) SET @sync_rowcount = @@rowcount";

                insInventoryCmd.Parameters.Add("@INV_ID", SqlDbType.Int);
                insInventoryCmd.Parameters.Add("@GPA_ID", SqlDbType.VarChar);
                insInventoryCmd.Parameters.Add("@label", SqlDbType.VarChar);

                insInventoryCmd.Parameters.Add("@Tier1_ID", SqlDbType.Int);
                insInventoryCmd.Parameters.Add("@Tier2_ID", SqlDbType.Int);
                insInventoryCmd.Parameters.Add("@Tier3_ID", SqlDbType.Int);
                insInventoryCmd.Parameters.Add("@Tier4_ID", SqlDbType.Int);
                insInventoryCmd.Parameters.Add("@FeatureType", SqlDbType.VarChar);
                insInventoryCmd.Parameters.Add("@Active", SqlDbType.Int);
         

                insInventoryCmd.Parameters.Add("@user_created", SqlDbType.UniqueIdentifier);
           
                insInventoryCmd.Parameters.Add("@user_edited", SqlDbType.UniqueIdentifier);

          
                insInventoryCmd.Parameters.Add("@sync_rowcount", SqlDbType.Int);
                insInventoryCmd.Parameters["@sync_rowcount"].Direction = ParameterDirection.Output;

                adaptorInventory.InsertCommand = insInventoryCmd;
    • Moved by Max Wang_1983 Friday, April 22, 2011 8:11 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Wednesday, April 2, 2008 9:16 PM