I am trying to use a new class in SqlCe 3.5 SP2 called SqlCeChangeTracking . This class (presumably) allows you to enable change tracking in a table without using RDA replication or synchronization services.
Assuming you have open SqlCeConnection, you enable change tracking in the table as follows:
SqlCeChangeTracking tracker = new SqlCeChangeTracking(conn); tracker.EnableTracking(TableName, TrackingKeyType.PrimaryKey, TrackingOptions.All);
This seems to work. When I open the SDF file and view it in SQL Server Management Studio, the table has three additional fields: __sysChangeTxBsn , __sysInsertTxBsn and __sysTrackingContext . According to sparse documentation, these columns (together with the __sysOCSDeletedRows system table) are used to track changes.
The problem is that these three columns always contain NULL values ββfor all rows , no matter what I do. I can add, delete, edit, etc., And these columns remain NULL no matter what (and no deleted records have ever appeared in __sysOCSDeletedRows ).
I have not found any documentation for this class at all, and the promised MSDN API does not exist. Does anyone know how to successfully use this class?
Update: I tried changing this to use TrackingKeyType.Guid , for example:
tracker.EnableTracking(TableName, TrackingKeyType.Guid, TrackingOptions.All);
but this raises SqlCeException 29010 "There is no primary key in the table. [Table name = EMPLOYEES]". This is strange because I create the table as follows:
CREATE TABLE EMPLOYEES (BADGE NVARCHAR(5) PRIMARY KEY, NAME NVARCHAR(50), DEPARTMENT NVARCHAR(10))
so he has a primary key (and I can see this PC when opening an SDF file in SQL Management Studio).
Update 2:. If I try to enable tracking with one of the other two parameters ( TrackingKeyType.None or TrackingKeyType.Max ), the application will instantly disappear and disappear without a trace, even using a try / catch block around the line. Never a sign.