Help with SqlCeChangeTracking

Posted by MusiGenesis on Stack Overflow See other posts from Stack Overflow or by MusiGenesis
Published on 2010-05-14T13:40:50Z Indexed on 2010/05/14 13:44 UTC
Read the original article Hit count: 913

Filed under:

I'm trying to use a new class in SqlCe 3.5 SP2 called SqlCeChangeTracking. This class (allegedly) lets you turn on change tracking on a table, without using RDA replication or Sync Services.

Assuming you have an open SqlCeConnection, you enable change tracking on a table like this:

SqlCeChangeTracking tracker = new SqlCeChangeTracking(conn);
tracker.EnableTracking(TableName, TrackingKeyType.PrimaryKey, 
    TrackingOptions.All);

This appears to work, sort of. 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 the sparse documentation, these columns (along 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 those columns remain NULL no matter what (and no deleted records ever show up in __sysOCSDeletedRows).

I have found virtually no documentation on this class at all, and the promised MSDN API appears non-existent. Anybody know how to use this class?

© Stack Overflow or respective owner

Related posts about sqlce