Creating a Full Replica

After you've created your Design Master you can create additional replicas from it by using the CreateReplica method. This method takes two required arguments. The first one is replicaName, which specifies the name and path of the full or partial replica to be created. The second argument is description, a string value describing the replica to be created.

The CreateReplica method can also take several optional arguments that let you specify the type of replica and its visibility, priority, and updatability. By omitting additional arguments, a full replica is created. This replica will have global visibility and will be fully updatable.

Hands-On 18-2 demonstrates how to create a full replica without optional arguments.

©Hands-On 18-2: Creating a Full Replica

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

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

Sub Make_FullReplica(DesignMasterName As String, _ NewRepName As String) Dim repDesignMaster As New JRO.Replica

On Error GoTo ErrorHandle

With repDesignMaster

.ActiveConnection = DesignMasterName

Creating and Manipulating Databases with ADO

.CreateReplica CurrentProject.Path & "\" & NewRepName, _ "Replica of " & DesignMasterName

End With

MsgBox "Full replica named " & NewRepName & " was created."

ExitHere:

Set repDesignMaster = Nothing Exit Sub ErrorHandle:

If Err.Number = -2147217897 Then

Kill CurrentProject.Path & "\" & NewRepName Resume

Else

MsgBox Err.Number & ": " & Err.Description Resume ExitHere End If End Sub

3. Execute the Make_FullReplica procedure by typing the following statement in the Immediate window and pressing Enter:

Make_FullReplica CurrentProject.Path & "\DM_Northwind.mdb", "Replica_North.mdb"

When you run the Make_FullReplica procedure, a new file named Replica_North.mdb is created. This file is a full replica of the DM_Northwind.mdb database.

You can create as many replicas of the original database (Design Master) as you want. All replicas created from the same Design Master belong to the same replica set, and only replicas from the same set can synchronize and exchange data with each other.

0 0

Post a comment