Merge Replication & Triggers



(Portions of this posting were previously posted in SQL Server CE newsgroup
but drew no response.)
Ok, so I made progress last week. I set up merge replication and got a table
out to the client, updated it, and am now attempting to replicate changes
back to the back end. The table that I'm experimenting with has an
insert/update trigger on it to keep anyone from changing the oxsitecode
values. The trigger DOES NOT in any way restrict updates to the oxsitelabel
values however, and they are what I'm updating (see code below).

Upon synchronization, if the trigger is in place, the changes to the
oxsitelabel values are NOT being merged into the back end, but a fresh copy
of the table FROM the back end is overwriting the table on the client, and my
changes are lost. If I drop the trigger on the table at the backend, the
synchronization yields the desired result of merging the updates from the
client into the back end.

So what about triggers and replication? The documentation I've dug up says
little about them except to suggest that they should present no problems.
One thing is for sure, our DBA isn't going to let anyone drop them! I'm
hoping someone who has been down this road before could provide some insight
as to what I'm up against. (As always, the code I'm playing with is shown


MergeRep mr = new MergeRep();
mr.CreateSubscription( "myRepDB" );
mr.Synchronize( "myRepDB" );

string str = "UPDATE cioxsitelist
SET oxsitelabel = 'Kilroy was here'
WHERE oxsitecode in (1,2,3,4,5)";

SqlCeConnection cn = new SqlCeConnection( @"Data Source=\My
Documents\myRepDB.sdf" );
SqlCeCommand cmd = new SqlCeCommand( str, cn );
cmd.CommandType = CommandType.Text;
catch( SqlCeException sex )
foreach( SqlCeError err in sex.Errors )
MessageBox.Show( err.Message, "SQL CE Error" );
catch( Exception ex )
MessageBox.Show( ex.Message, "Error" );

mr.Synchronize( "myRepDB" );




You might ask in the sqlce newsgroup for a bit more luck.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

RDA or Merge Replication with ActiveSync Trigger 3
Merge Replication 4
merge replication 1
merge replication 1
merge replication 0
Merge Replication 3
merge replication 0
Merge Replication 6