Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 857881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:28:04+00:00 2026-05-15T08:28:04+00:00

I’m trying to use a new class in SqlCe 3.5 SP2 called SqlCeChangeTracking .

  • 0

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 successfully?

Update: I tried changing this to use TrackingKeyType.Guid, like so:

tracker.EnableTracking(TableName, TrackingKeyType.Guid, 
    TrackingOptions.All);

but this throws SqlCeException 29010 “The table does not have a primary key. [ Table name = EMPLOYEES ]”. This is weird, because I’m creating the table like this:

CREATE TABLE EMPLOYEES (BADGE NVARCHAR(5) PRIMARY KEY, NAME NVARCHAR(50), 
    DEPARTMENT NVARCHAR(10))

so that it does have a primary key (and I can see this PK when I open the SDF file in SQL Management Studio).

Update 2: If I try to enable tracking with one of the other two options (TrackingKeyType.None or TrackingKeyType.Max) the app dies instantly and vanishes without trace, even with a try/catch block around the line. Never a good sign.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T08:28:06+00:00Added an answer on May 15, 2026 at 8:28 am

    I believe there is an issue when enabling the change tracking that it doesn’t start working until you close and re-open the SqlCeConnection after you call EnableTracking. Here’s some simple code that shows this, the first insert and update do nothing to the tracking columns, but after calling Close and Open on the connection, the 2nd update will be tracked.

    using (var cmd = new SqlCeCommand("CREATE TABLE t1 (c1 int primary key, c2 int)", conn))
    {
        cmd.ExecuteNonQuery();
    
        using (var ceCt = new SqlCeChangeTracking(conn))
        {
            ceCt.EnableTracking("t1", TrackingKeyType.PrimaryKey, TrackingOptions.All);
        }
    
        cmd.CommandText = "insert into t1 (c1, c2) values (1,1)";
        cmd.ExecuteNonQuery();
    
        cmd.CommandText = "select __sysChangeTxBsn from t1 where c1 = 1";
        var val = cmd.ExecuteScalar();
        // This will be null since the connection has not been closed/reopened
        Console.WriteLine((val is DBNull) ? "NULL" : val);
    
        cmd.CommandText = "update t1 set c2 = 2 where c1 = 1";
        cmd.ExecuteNonQuery();
    
        cmd.CommandText = "select __sysChangeTxBsn from t1 where c1 = 1";
        val = cmd.ExecuteScalar();
        // This will be null since the connection has not been closed/reopened
        Console.WriteLine((val is DBNull) ? "NULL" : val);
    
        // Recycle the connection to get change tracking working
        conn.Close();
        conn.Open();
    
        cmd.CommandText = "update t1 set c2 = 3 where c1 = 1";
        cmd.ExecuteNonQuery();
    
        cmd.CommandText = "select __sysChangeTxBsn from t1 where c1 = 1";
        val = cmd.ExecuteScalar();
        // This will be non-null and subsequent updates will increase it.
        Console.WriteLine((val is DBNull) ? "NULL" : val);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.