Microsoft KB Archive/304058

= HOWTO: Perform Replication by Using SSCERelay and ActiveSync =

Article ID: 304058

Article Last Modified on 2/22/2007

-

APPLIES TO


 * Microsoft SQL Server 2000 Windows CE Edition

-



This article was previously published under Q304058



SUMMARY
This article describes how to perform Replication by using the SQL Server CE Relay (SSCERelay) executable, Sscerelay.exe, and ActiveSync.



MORE INFORMATION
The following steps describe how to use SSCERelay and ActiveSync to replicate data from the Customers table in the Northwind sample database to a Windows CE device by using Microsoft® SQL Server™ 2000 Windows® CE Edition (SQL Server CE) Merge Replication.  Run SQL Server CE Relay manually. For example:  On a Microsoft Windows 2000-based computer, open a command prompt. Change the directory to Program Files\Microsoft SQL Server CE\Relay. On the command line type the following command sscerelay /clientport 81 /servername  /serverport 80

where  is the name of your Microsoft Internet Information Services (IIS) server.

Press ENTER to run the command.

NOTE: Optionally, you can specify the /register option at the end of the preceding command line.

 Create a new Microsoft eMbedded Visual Basic application.</li>  Add a command button to the default form, and then paste the following code in for the command: Private Sub Command1_Click ' Declare the SQL Server CE ActiveX Replication Object Control. Dim ce As SSCE.Replication

' Create the Replication Object Set ce = CreateObject(&quot;SSCE.Replication.1.0&quot;)

' Set Replication properties ce.InternetURL = &quot;http://myIISServerName/ssce/sscesa10.dll&quot; ce.InternetProxyServer = &quot;ppp_peer:81&quot; ce.InternetLogin = &quot;myInternetLogin&quot; ce.InternetPassword = &quot;myInternetPassword&quot; ce.Publisher = &quot;mySQLServer&quot; ce.PublisherDatabase = &quot;Northwind&quot; ce.Publication = &quot;myPublication&quot; ce.PublisherLogin = &quot; &quot; ce.PublisherPassword = &quot;<user_account_password>&quot; ce.SubscriberConnectionString = &quot;data source=\Local.sdf&quot; ce.Subscriber = &quot;myCESub&quot;

' Create the new anonymous subscription ce.AddSubscription (1)

' Perform the first synchronization to download the initial snapshot by ' calling the Initialize, Run and Terminate methods On Error Resume Next ce.Initialize If ce.ErrorRecords.Count > 0 Then ShowErrors ce.ErrorRecords Else On Error Resume Next ce.Run If ce.ErrorRecords.Count > 0 Then ShowErrors ce.ErrorRecords End If   ce.Terminate

End If

Set ce = Nothing

End Sub

Sub ShowErrors(ErrColl As SSCEErrors)

'Initailize error variables to view error collection Dim ErrRec As Object   'SSCE.ErrorRecords Dim param As Object Dim strErr As String strErr = &quot;&quot;

For Each ErrRec In ErrColl strErr = strErr & &quot;Source: &quot; & ErrRec.Source & vbCrLf strErr = strErr & &quot;Number: &quot; & Hex(ErrRec.Number) & vbCrLf strErr = strErr & &quot;NativeError: &quot; & ErrRec.NativeError & vbCrLf strErr = strErr & &quot;Description: &quot; & ErrRec.Description & vbCrLf For Each param In ErrRec.Params strErr = strErr & &quot;Param&quot; & &quot; = &quot; & param.param & vbCrLf Next param strErr = strErr & vbCrLf Next ErrRec MsgBox strErr, vbOKOnly

End Sub </li></ol>