Programming Anonymous Internet Subscriptions

Microsoft® ActiveX® replication controls can be programmed to synchronize data over the Internet. After the Publisher and Distributor are configured for publishing over the Internet and a publication enabled for anonymous subscriptions is created, an application using a ActiveX replication control can synchronize with the publication data.

Examples
Distribution Control

This example demonstrates how a Microsoft Visual Basic® program can configure the SQL Distribution control to synchronize data with an anonymous SQL Server Subscriber over the Internet:

'Initialize the replication control.

Dim oSQLDistribution As New SQLDistribution    

  

'Configure the control for an anonymous subscription.

oSQLDistribution.Publisher = "PublisherName"

oSQLDistribution.PublisherDatabase = "PublisherDatabaseName"

oSQLDistribution.Publication = "PublicationName"

oSQLDistribution.PublisherSecurityMode = DB_AUTHENTICATION

oSQLDistribution.PublisherLogin = "Login"

oSQLDistribution.PublisherPassword = "Password"

oSQLDistribution.SubscriberDatasourceType = SQL_SERVER

oSQLDistribution.Subscriber = "SubscriberName"

oSQLDistribution.SubscriberDatabase = "SubscriberDatabaseName"

oSQLDistribution.SubscriptionType = ANONYMOUS

oSQLDistribution.SubscriberSecurityMode = DB_AUTHENTICATION

oSQLDistribution.SubscriberLogin = "Login"

oSQLDistribution.SubscriberPassword = "Password"

  

'Configure the control to access the Publisher over the Internet

'using TCP/IP.  You must provide a IP address and socket number or a

‘named which can be resolved by the naming service.

oSQLDistribution.PublisherNetwork = 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

oSQLDistribution.Run

oSQLDistribution.Terminate

  


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.


Merge Control

This example demonstrates how a Visual Basic program can configure the Merge Control to synchronize data for an anonymous subscription over the Internet:

'Initialize the SQL Merge Control.

Dim WithEvents sm As SQLMerge

  

Private Sub Command1_Click()

   Set sm = New SQLMerge

  

   'Setup distributor

   sm.DistributorAddress = "SamplePublisher.company.com"

   sm.DistributorNetwork = TCPIP_SOCKETS

   sm.Distributor = "SamplePublisher"

   sm.FileTransferType = FTP_TRANSFER

   sm.FtpAddress = "SamplePublisher.company.com"

   sm.FtpLogin = "anonymous"

   sm.FtpPassword = "user@company.com"

  

   'Setup publisher

   sm.PublisherAddress = "SamplePublisher.company.com"

   sm.PublisherNetwork = TCPIP_SOCKETS

   sm.Publisher = "SamplePublisher"

   sm.PublisherDatabase = "SamplePublisherDb"

   sm.Publication = "SamplePublication"

  

   'Existing sql publisher anon subs:

   sm.Subscriber = "SampleSubscriber"

   sm.SubscriberDatabase = "SampleSubscriberDb"

   sm.SubscriberDatasourceType = SQL_SERVER

   sm.SubscriptionType = ANONYMOUS

  

  'Setup security settings:

  'distributor and publisher use sql authentication

  'subscriber uses nt authentication

   sm.DistributorSecurityMode = STANDARD

   sm.PublisherSecurityMode = STANDARD

   sm.SubscriberSecurityMode = NT_AUTHENTICATION

   sm.DistributorLogin = "sample_login"

   sm.PublisherLogin = "sample_login"

   sm.DistributorPassword = "sample_pwd"

   sm.PublisherPassword = "sample_pwd"

  

   sm.Initialize

   sm.Run

   sm.Terminate

  

End Sub

  

Private Sub sm_Status(ByVal Message As String, ByVal Percent As Long)

    Label1 = Message

End Sub

  

See Also
Adding an Anonymous Subscription Configuring Publications for the Internet

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.