Previous Page

Synchronizing Replicas

For database replication to be useful, replicas must communicate with one another to keep up-to-date information. Synchronization is the process of making the design and data in the replicas identical. As changes are made to the existing records in one replica, those changes are communicated to each of the other replicas that have that same record. Similarly, new records added or old records deleted from one replica are communicated to the other replicas in the replica set.

You can synchronize one replica with another by using Microsoft Access menu commands, the Windows Briefcase or Visual Basic code. The method you use corresponds to the method you used to implement database replication.

   To synchronize two replicas by using Microsoft Access menu commands

 On the Tools menu, point to Replication, and then click Synchronize Now.

   To synchronize two replicas by using the Windows Briefcase

1   Double-click the My Briefcase icon on your desktop, and click the database file.

2   On the Briefcase menu, click Update Selection. If you want to synchronize all the replicas in the Briefcase, click Update All.

You can also keep the replicas synchronized by using the Synchronize method in Visual Basic code. The syntax of the Synchronize method is:

database.Synchronize pathname, exchange

Database is an object variable that represents the Database object that is the replica. In the pathname argument, you specify the path to the target replica. You can use the pathname argument to synchronize one user's replica with another replica in the set. You can set the exchange argument to a constant that indicates which direction to synchronize changes between the two replicas. For example, the following code sets the exchange argument to the dbRepImpExpChanges constant to perform a two-way synchronization between replicas.

Sub SynchronizeDBs(strDBName, strSyncTargetDB)
   Dim dbs As Database
   Set dbs = OpenDatabase(strDBName)
   ' Synchronize replicas (bidirectional exchange).
   dbs.Synchronize strSyncTargetDB, dbRepImpExpChanges
   dbs.Close
End Sub

If you do not provide an exchange argument, the exchange is bidirectional (import and export).

When Microsoft Jet synchronizes replicas, it always synchronizes design changes before it synchronizes changes to data. The design of both replicas must be at the same version level before data can be exchanged. For example, even if you set the exchange argument to the dbRepExportChanges constant to specify that data changes flow only from the current replica to the designated target, design changes could be made to the current replica if it has a lower version number than the target replica.

If you want to prevent users from making changes to the design of your database, do not make the replica on the network server the Design Master. Instead, keep the Design Master replica at a network location that is accessible only by you. As you make changes to your application, you can synchronize with the replica on the server and rely on it to pass these changes on to other replicas the replica set.

Note   You can now synchronize replicas over the Internet. Before you can synchronize over the Internet, you must configure your Internet server for replication. To configure your Internet server, you need Replication Manager, which includes a wizard that takes you through the configuration process. For more information on Replication Manager, see "Replication Manager" earlier in this chapter.

© 1996 Microsoft Corporation. All rights reserved.

Next Page


Casa de Bender