Microsoft Jet and Replication Objects
The following three examples demonstrate the Synchronize method. This example demonstrates how to update changes between a Design Master and a replica with the Synchronize method.
Public Sub DirectSync()
Dim repMaster As New JRO.Replica
Dim RepNorthwind As New JRO.Replica
Dim conn As New ADODB.Connection
' Open the database.
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data source=C:\Program Files\Microsoft Office\" & _
"Office\Samples\Northwind.mdb;"
' If a replica of the database exists, it is deleted.
repMaster.ActiveConnection = conn
' "C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb"
If (Dir("C:\Program Files\Microsoft Office\" & _
"Office\Samples\Replica of Northwind.mdb") <> "") Then Kill _
("C:\Program Files\Microsoft Office\" & _
"Office\Samples\Replica of Northwind.mdb")
' Create a new replica of the database.
repMaster.CreateReplica "C:\Program Files\Microsoft Office\" & _
"Office\Samples\Replica of Northwind.mdb", _
"Replica1 for Northwind.mdb", _
jrRepTypeFull, jrRepVisibilityGlobal
' New values are put into tab1.
On Error Resume Next
conn.Execute "drop table tab1"
On Error GoTo 0
conn.Execute "create table tab1 ( col1 int)"
conn.Execute "insert into tab1 values (1)"
conn.Execute "insert into tab1 values (2)"
' Synchronize the values.
repMaster.Synchronize "C:\Program Files\Microsoft Office\" & _
"Office\Samples\Replica of Northwind.mdb", jrSyncTypeImpExp, _
jrSyncModeDirect
End Sub
This example demonstrates how to use the Synchronize method for Internet synchronization. Note that prior to synchronization, the Internet replication setup must be completed.
Public Sub InternetSync()
Dim rep As New JRO.Replica
' This is the replica on your local machine.
rep.ActiveConnection = "C:\Program Files\Microsoft Office\" & _
"Office\Samples\Northwind.mdb"
' The name of the Internet server is "my_server"
' and is configured for Internet replication.
rep.Synchronize "http://MY_SERVER", jrSyncTypeImpExp, _
jrSyncModeInternet
Set rep = Nothing
End Sub
This example demonstrates how to use the Synchronize method with indirect synchronization.
Public Sub IndirectSync()
Dim repMaster As New JRO.Replica
repMaster.ActiveConnection = "C:Program Files\" & _
"Microsoft Office\Office\Samples\Northwind.mdb"
' The Synchronizer that manages the replica is called
' SynchronizerName, the one with which
' you want to exchange data.
repMaster.Synchronize "SynchronizeName", jrSyncTypeImpExp, _
jrSyncModeIndirect
End Sub