Using the Microsoft® ActiveX® replication controls using Microsoft Visual Basic® Scripting Edition is supported with the following limitations:
This example demonstrates how an HTML page using VBScript can configure the SQL Distribution control to synchronize data for an anonymous subscription over the Internet:
<html>
<head>
<script LANGUAGE="VBScript">
<!--
Sub window_onload()
Call DoSync()
end sub
Sub DoSync()
Dim oErrorObject
On Error Resume Next
'Configure the control for an anonymous subscription.
oSQLDistribution.Publisher = "PublisherName"
oSQLDistribution.PublisherDatabase = "PublisherDatabase"
oSQLDistribution.Publication = "PublicationName"
oSQLDistribution.PublisherSecurityMode = 0 'DB_AUTHENTICATION
oSQLDistribution.PublisherLogin = "Login"
oSQLDistribution.PublisherPassword = "Password"
oSQLDistribution.SubscriberDatasourceType = 0 'SQL_SERVER
oSQLDistribution.Subscriber = "SubscriberName"
oSQLDistribution.SubscriberDatabase = "SubscriberDatabase"
oSQLDistribution.SubscriptionType = 2 'ANONYMOUS
oSQLDistribution.SubscriberSecurityMode = 0 'DB_AUTHENTICATION
oSQLDistribution.SubscriberLogin = "Login"
oSQLDistribution.SubscriberPassword = "Password"
'Configure the control to access the Publisher over the Internet using TCP/IP.
oSQLDistribution.PublisherNetwork = 1 'TCPIP_SOCKETS
oSQLDistribution.PublisherAddress = "111.11.11.11,1433"
'Configure the control to use FTP to download all initial snapshot files.
oSQLDistribution.FTPAddress = "111.11.11.11"
oSQLDistribution.FTPPort = 21
oSQLDistribution.FTPLogin = "FTPLogin"
oSQLDistribution.FTPPassword = "FTPPassword"
'Synchronize the data.
oSQLDistribution.Initialize
If (oSQLDistribution.ErrorRecords.Count > 0) Then
'Display each error message
For Each oErrorObject in oSQLDistribution.ErrorRecords
MsgBox oErrorObject.Description, vbCritical, "SQL Distribution Failure"
Next
Else
oSQLDistribution.Run
If (oSQLDistribution.ErrorRecords.Count > 0) Then
'Display each error message
For Each oErrorObject in oSQLDistribution.ErrorRecords
MsgBox oErrorObject.Description, vbCritical, "SQL Distribution Failure"
Next
Else
oSQLDistribution.Terminate
If (oSQLDistribution.ErrorRecords.Count > 0) Then
'Display each error message
For Each oErrorObject in oSQLDistribution.ErrorRecords
MsgBox oErrorObject.Description, vbCritical, "SQL Distribution Failure"
Next
End If
End If
End If
End Sub
Sub oSQLDistribution_Status(Message, Percent)
' Display message here
end sub
</script>
<object id="oSQLDistribution" classid="clsid:05E219F5-BB55-11D0-94E7-00C04FC2DB9C" width="0" height="0">
</object>
<object id="oSQLMerge" classid="clsid:84923184-F94B-11D0-A8E8-00C04FC2DEB3" width="0" height="0">
</object>
Note The above properties are the same for both the SQL Merge and SQL Distribution controls. You can replace references to the SQLDistribution object with references to the SQLMerge object.