DesignMasterID Property Example (VC++)

This example uses the DesignMasterID property, ReplicaID property, and Synchronize method to move the DesignMaster to a replica.

/*   Notes:
   1)   Open current DesignMaster in exclusive mode.
      Cast the second operand as a BOOL to invoke the
      correct overloaded OpenDatabase method.
   2)   Open the database that will become the new
      DesignMaster.
   3) Synchronize will first copy the old
      DesignMaster's DesignMasterID to the replica. 
      This will update the replica's DesignMasterID 
      property to point to itself.
*/
void SetNewDesignMasterX( 
                        LPCTSTR szOldDM, 
                        LPCTSTR szNewDM )
{
   CdbDBEngine   dbeng;
   CdbDatabase   dbsOld, dbsNew;
                                    // note 1
   dbsOld = dbeng.OpenDatabase(szOldDM, (BOOL)TRUE);
   dbsNew = dbeng.OpenDatabase(szNewDM);   // note 2
   dbsOld.SetDesignMasterID(
                     (LPCTSTR)dbsNew.GetReplicaID());
   dbsOld.Synchronize(szNewDM, 
                     dbRepImpExpChanges);// note 3
   dbsOld.Close();
   dbsNew.Close();
   return;
}