" Specified cast is not valid " While Syncing back from client to server

Apr 17 at 12:03 PM
I tried to implement sync toolkit and managed successfully to sync from server to client (Thanks for the detailed documentation). Now if I update any rows in the sqlite database (client side), I am getting " Specified cast is not valid " exception while syncing back to the server. I believe i have perfectly followed the documentation given. It would be a great help if you could add some thoughts.

Stack trace are as below:
at Microsoft.Synchronization.ClientServices.SQLite.SQLiteHelper.ReadCol(ISQLiteStatement stmt, Int32 index, Type clrType)
at Microsoft.Synchronization.ClientServices.SQLite.SQLiteHelper.GetChanges(OfflineSchema schema, DateTime lastModifiedDate)
at Microsoft.Synchronization.ClientServices.SQLite.SQLiteManager.GetChanges(Guid state, DateTime lastSyncDate)
at Microsoft.Synchronization.ClientServices.SQLite.SQLiteContext.<>c__DisplayClass12.<GetChangeSet>b__11()
at System.Threading.Tasks.Task1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()
at Microsoft.Synchronization.ClientServices.SQLite.SQLiteContext.<GetChangeSet>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.Synchronization.ClientServices.CacheController.<EnqueueUploadRequest>d__a.MoveNext()

Database Script are as follows,

USE [SqlliteSyncDB]
GO
/ Object: Table [dbo].[Users] Script Date: 4/17/2014 4:29:56 PM /
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Users](
[UserID] [int] IDENTITY(1,1) NOT NULL,
[UserName] [nvarchar](50) NOT NULL,
[Password] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED
(
[UserID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

Thanks in advance.
Regards,
-Ansary Rasheed
Apr 20 at 7:54 AM
Hi, I have the same issue.
The data from server are synchronized to the client without any problem, but if I modify
Any row on the client and try to synch back to the server I get the error below.
By Daniele
Apr 21 at 5:29 AM
Hi,
I am using type of my primary key as 'INT' in SQL server database and the problem raised due to this usage. I changed my primary key type as varchar and it worked.I hope there might be some issues while typecasting integer from sqlite to sql. I am unaware of what is exactly happening with INT scenario. Please let me know if anyone have a comment on this.

Regards,
-Ansary Rasheed
Coordinator
Apr 22 at 8:26 AM
Hi Ansary, hi Daniele;

I ve fixed this issue in the last Nuget package.
Check the new package (https://www.nuget.org/packages/SyncClient.SQLite )
By the way, this package works with the last SQLite version (3.8.4.2)

If you works with the source code, I will make a check in as soon as possible :)

Sébastien
Apr 24 at 3:29 PM
Edited Apr 24 at 3:30 PM
Hi Sébastien,

Thank you very much for the timely assistance. It works like a charm. Before I used the previous version of Nuget (downloaded on day before the new update :) ). Anyway I am really appreciating the effort taken to get the issue resolved.

-Regards,
Ansary.R
Apr 24 at 4:35 PM
Hi Sebastien,
thanks a lot for your support.
I have tried the last version and the synchronization works well now.

Regards,
Daniele B.
Coordinator
Apr 25 at 12:58 PM
You're welcome !!! :)

Sébastien
Nov 8 at 11:32 AM
how to set synchronisation direction in this package.