Synchronizing Replicas

Synchronization allows reconciliation of all changes between replicas. This means that any changes, additions, or deletions can be exchanged between replicas, thus keeping all the copies current and up to date. In JRO, there are three types of synchronization, as shown in Table 18-1.

Table 18-1: Replica synchronization types

Synchronization Type

Constant

Description

Bi-directional, import/export

jrSyncTypeImpExp

Updates are mutual; they flow from the target replica to the source replica and from the source replica to the target replica.

Import only

jrSyncTypeImport

Updates will flow only from the target replica to the source replica.

Export only

jrSyncTypeExport

Updates will flow only from the source replica to the target replica.

In addition to the type of synchronization, you can specify the synchronization mode (Table 18-2).

Table 18-2: Replica synchronization modes

Synchronization Mode

Constant

Description

Direct (default setting)

jrSyncModeDirect

Both replicas must reside on computers connected to a common local area network (LAN) or wide area network (WAN).

Indirect

jrSyncModeIndirect

When a replica resides on a computer disconnected from a network, updates are placed in a dropbox folder and are automatically synchronized when the user connects to the network. This process requires synchronizers to be installed both on the network and on the disconnected computer.

Internet

jrSyncModeInternet

Used for synchronizing with a database connected to a web server.

To synchronize one replica with another, both database files must belong to the same replica set. Each replica set is identified by a unique replica set ID. For two replicas to belong to the same replica set, they must be created from the same Design Master. It is not sufficient to create replicas from the same nonreplicable original database. If you created two replicas that belong to different replica sets and want to bring data from one replica set to another, you can copy and paste or import the data. You cannot use synchronization to reconcile the changes between two replicas from different replica sets.

Hands-On 18-7 demonstrates how to use direct, bidirectional (two-way) synchronization.

Creating and Manipulating Databases with ADO

| Hands-On 18-7: Synchronizing Replicas

1. Switch to the Visual Basic Editor window and insert a new module.

2. In the module's Code window, enter the Sync_Replicas procedure as shown below.

Sub Sync_Replicas(strRep As String, strReplica As String, _ Optional sncType As SyncTypeEnum, _ Optional sncMode As SyncModeEnum) Dim repDesignMaster As New JRO.Replica repDesignMaster.ActiveConnection = strRep

' exchange data and design changes between replicas repDesignMaster.Synchronize strReplica, sncType, sncMode Set repDesignMaster = Nothing MsgBox strRep & vbCrLf & _ "and " & vbCrLf & _ strReplica & vbCrLf & _ "were synchronized."

End Sub

Notice that the Sync_Replicas procedure takes two required and two optional arguments.

3. Run the Sync_Replicas procedure from the Immediate window by typing the following statement and pressing Enter:

Sync_Replicas CurrentProject.Path & "\DM_Northwind.mdb", CurrentProject.Path & "\Replica_North.mdb", jrSyncTypeImpExp, jrSyncModeDirect

^^ Note: The above statement must be entered on one line in the Immediate window.

When you execute this statement the full replica named Replica_North.mdb (see Hands-On 18-2) will be synchronized with the Design Master named DM_Northwind.mdb (see Hands-On 18-1).

Part II

0 0

Post a comment