Getting the SyncSession.SyncNewReceivedAnchor

250 Views Asked by At

I am trying to get the Sync New Received Anchor to be stored in my Server Side database. The Purpose is to store the Time Stamp in which we have received the data from the client. To achieve this we are using the following command:

    SqlCommand selectNewAnchorCommand = new SqlCommand();
    string newAnchorVariable = "@" + SyncSession.SyncNewReceivedAnchor;
    selectNewAnchorCommand.CommandText = "SELECT " + newAnchorVariable + " = GETUTCDATE()";
    selectNewAnchorCommand.Parameters.Add(newAnchorVariable, SqlDbType.DateTime);
    selectNewAnchorCommand.Parameters[newAnchorVariable].Direction = ParameterDirection.Output;
    selectNewAnchorCommand.Connection = serverConnection;
    this.serverProvider.SelectNewAnchorCommand = selectNewAnchorCommand;

and once we receive th Anchor i am using it in the following way:

sqlCmdTransactionMaster.Parameters.Add("@" + SyncSession.SyncNewReceivedAnchor, SqlDbType.DateTime); The Output should be "Current Date" but i am getting the following date

"1753-01-01 12:00:00.000"

This date is a default date available in SQL Server.

Environment : Visual Studio 2008 , Sync Framework 2.1 & SQL Server 2008 (with Tracking False)

The Purpose of this whole exercise is to get the Server date in the table when the record is inserted in the server. Is there any other way of getting that done?

Please let me know where i am going wrong in this:

Thanks in Advance Biju Melayil

1

There are 1 best solutions below

0
On

I think you would normally do this with change tracking enabled and by using the change tracking function CHANGE_TRACKING_CURRENT_VERSION() - http://msdn.microsoft.com/en-us/library/bb933945.aspx

This example explains a lot: http://msdn.microsoft.com/en-us/library/cc305322.aspx

But maybe enabling change tracking is not an option for you?