locked
Unable to set session parameters in DbServerSyncProvider. RRS feed

  • Question

  • Hi

    I am new to SSCE, Sync services is the one that suites to our new project implementation with Global Database as SQL 2005 and SQLCEs as client local databases.

     

    I am impletenting sample with 'Uploadonly', inserting a row into client database, and trying to sync with global database, I have created triggers for insert, update,delete and stored procedure to insert data at serverside.

    But I am getting this exception at

     

    syncAgent.Synchronize();

     

    Unable to set session parameters in DbServerSyncProvider. Cannot obtain the value for command parameter 'Name'.

     

    // insert row com

    SqlCommand insProjectCmd = new SqlCommand();

    insProjectCmd.CommandType = CommandType.StoredProcedure;

    insProjectCmd.CommandText = "sp_Project_applyinsert";

    insProjectCmd.Parameters.Add("@ProjectUUID", SqlDbType.UniqueIdentifier);

    insProjectCmd.Parameters.Add("@Description", SqlDbType.NText);

    insProjectCmd.Parameters.Add("Name", SqlDbType.NVarChar);

    insProjectCmd.Parameters.Add("PartNumber", SqlDbType.VarChar);

    insProjectCmd.Parameters.Add("ChangeLevel", SqlDbType.VarChar);

    insProjectCmd.Parameters.Add("SoftwareVersion", SqlDbType.VarChar);

    insProjectCmd.Parameters.Add("ApplicationVersion", SqlDbType.VarChar);

    insProjectCmd.Parameters.Add("@" + SyncSession.SyncClientIdHash, SqlDbType.Int);

    insProjectCmd.Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.Binary, 8);

    insProjectCmd.Parameters.Add("@" + SyncSession.SyncRowCount, SqlDbType.Int).Direction = ParameterDirection.Output;

    insProjectCmd.Connection = sqlcon;

    adaptorProject.InsertCommand = insProjectCmd;

    serverSyncProvider.SyncAdapters.Add(adaptorProject);

     

    I am adding parameters like that, i understand that, parameter values will be added from the session, I need not to pass parameter values explicitly.

     

    Please throw some light where am I doing mistake.

     

    Thanks in advance

    • Moved by Max Wang_1983 Friday, April 22, 2011 10:58 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Thursday, April 19, 2007 6:24 PM

Answers

  • Hi,

     

    True, you don't need to pass parameter values; the runtime will do that for you. Do you have a column with name "Name" in the client table?

     

    Thanks

    Thursday, April 19, 2007 7:53 PM

All replies

  • Hi,

     

    True, you don't need to pass parameter values; the runtime will do that for you. Do you have a column with name "Name" in the client table?

     

    Thanks

    Thursday, April 19, 2007 7:53 PM
  • No Worries.... I got it...its my mistake...typo
    Thursday, April 19, 2007 10:35 PM
  • Hi,

     

       I receive the following error when I try to synchronize after deleting a record.

     

    The DbServerSyncProvider is unable to apply changes at the server, because the parameter 'sync_rowcount' is not declared.

     

    My delete command and procedure declarations are as below:

     

     SqlCommand deleteVariableCmd = new SqlCommand();

     

    deleteVariableCmd.CommandType = CommandType.StoredProcedure;

    deleteVariableCmd.CommandText = "sp_VariablesSingleUnit_applydelete";

    deleteVariableCmd.Parameters.Add("@VariableUUID",SqlDbType.UniqueIdentifier);

    deleteVariableCmd.Parameters.Add("@ProjectUUID",SqlDbType.UniqueIdentifier);

    deleteVariableCmd.Parameters.Add("@TemplateUUID",SqlDbType.UniqueIdentifier);

    deleteVariableCmd.Parameters.Add("@" + SyncSession.SyncClientIdHash, SqlDbType.Int);

    deleteVariableCmd.Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor,SqlDbType.Binary,8);

    deleteVariableCmd.Parameters.Add("@"+SyncSession.SyncRowCount,SqlDbType.Int).Direction = ParameterDirection.Output;

    deleteVariableCmd.Connection = sqlcon;

     

    adaptorVariable.DeleteCommand = deleteVariableCmd;

     

     CREATE PROCEDURE [dbo].[sp_VariablesSingleUnit_applydelete] (

    @VariableUUID Uniqueidentifier,

    @ProjectUUID Uniqueidentifier,

    @TemplateUUID Uniqueidentifier,

    @sync_client_id_hash int,

    @sync_last_received_anchor binary(8),

    @sync_rowcount int out)

     

     

    I am not sure what mistake I am doing. Please let me know what needs to be done. Also, I have another question:

     

    Is SyncSession.SyncRowCount a required parameter? What happens if we do not use this sesssion parameter?

     

     

    Thanks,

    Kamesh

    Thursday, July 5, 2007 4:30 PM
  • Kamesh,

     

    In case you still haven't found the issue, or anyone else has this problem...

     

     I too had this issue and finally realised that @sync_rowcount in my Stored Procedure parameter list should now actually be @sync_row_count.

     

    It must have changed somewhere along the way.

     

    Regards,

     

    Glen

     

    Thursday, August 23, 2007 5:09 AM
  • I too got this error, reason was different:

     

    My StoredProcs are custom sps, with so many conditions before update.

    Update will be executed only if it met all the conditions then initializing @sync_rowcount, otherwise @sync_rowcount will not be set which is casuing the error message.

     

    Friday, September 7, 2007 9:53 PM
  •  

    Please make sure that the output parameter for the syncRowCount is the same as the SyncSession.SyncRowCount.

    also please noticed that the server provider uses this value to determine if the changes was applied successfully or not, in cases you SP did you set this value correctly, the server provider may report failed apply.

     

    thanks

    Yunwen

    Saturday, September 8, 2007 5:48 PM
    Moderator
  • Hi Rafik,

     

    just a quick question - what should I do If i have NO column with the same name, but i WANT to specify the parameter?
    All my experiments with

    Code Snippet
    incrementalInsertCommand.Parameters.Add(
    "@columns", SqlDbType.VarChar, 50).Value = columnString;

     

    or

    Code Snippet
    incrementalInsertCommand.Parameters.AddWithValue(
    "@idcolumn", idColumnName);

     

     

    failed so far.

     

    Thanks,

    Andreas

    Monday, May 19, 2008 7:32 AM