HOWTO: Perform RDA Pull by Using SSCERelay and ActiveSync (302349)



The information in this article applies to:

  • Microsoft SQL Server 2000 Windows CE Edition

This article was previously published under Q302349

SUMMARY

This article describes how to perform Remote Data Access (RDA) pull by using SSCERelay and ActiveSync.

MORE INFORMATION

The following steps describe how to use SSCERelay and ActiveSync to pull data from the Customers table in the Northwind sample database to a Windows CE device by using RDA.
  1. Run SQL Server CE relay manually: Open a command prompt on Windows 2000, change the directory to \Program Files\Microsoft SQL Server CE\Relay, and then run the following command to start SSCERelay manually:

    sscerelay /clientport 81 /servername <IIS server name> /serverport 80

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

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

  2. Create a new Microsoft eMbedded Visual Basic application: Add a command button to the default form and paste the following code in for the command:
    Private Sub Command_Click()
    
    ' Using USB connection with Relay
    Const strConnect = "Provider=microsoft.sqlserver.oledb.ce.1.0;Data Source=\Local.sdf"
    
     ' Declare the SQL Server CE ActiveX Control RDA Object Control.
    
        Dim ceRDA As ssce.RemoteDataAccess
    
       ' Create the RDA Object
    
       Set ceRDA = CreateObject("SSCE.RemoteDataAccess.1.0")
    
       ' Set Internet properties
    
        ceRDA.InternetURL = "http://myIISServerName/ssce/sscesa10.dll"
        ceRDA.InternetProxyServer = "ppp_peer:81"
    
    '   ceRDA.InternetLogin = "MyInternetLogin"
    '   ceRDA.InternetPassword = "MyInternetPassword"
    
       ceRDA.LocalConnectionString = strConnect
       On Error Resume Next
       ceRDA.Pull "LocalCustomers", "SELECT * FROM Customers", "provider=sqloledb;data source=MySQLServer;Initial Catalog=Northwind;user id=myUser;password=myPassword", 0  
       ShowErrors (ceRDA.ErrorRecords)
       Set ceRDA = Nothing
    End Sub
    
    
    
    Sub ShowErrors(ErrColl As SSCEErrors)
    
      'Initialize error variables to view error collection
      Dim ErrRec As Object  'SSCE.ErrorRecords
      Dim param As Object
      Dim strErr As String
        
      strErr = ""
    
      For Each ErrRec In ErrColl
         strErr = strErr & "Source: " & ErrRec.Source & vbCrLf
         strErr = strErr & "Number: " & Hex(ErrRec.Number) & vbCrLf
         strErr = strErr & "NativeError: " & ErrRec.NativeError & vbCrLf
         strErr = strErr & "Description: " & ErrRec.Description & vbCrLf
         For Each param In ErrRec.Params
          strErr = strErr & "Param" & " = " & param.param & vbCrLf
         Next param
         strErr = strErr & vbCrLf
      Next ErrRec
      
      MsgBox strErr, vbOKOnly
    
    End Sub
    					

    NOTES:

    • The InternetProxyServer property must be set to ppp_peer:81 (all lower case). If you try "PPP_Peer:81" (uppercase) the application may not work.
    • Replace "Local.sdf" with the name of the database on the device.
    • Replace "myIISServerName" with the correct IIS computer name and specify the appropriate IIS authentication parameters.
    • The URL that is used in this code assumes that the IIS virtual directory name is "ssce". Replace "ssce" with the modified name if needed.
    • Edit the pull method properties to reflect the correct SQL Server name, user ID, and password.
  3. Add references: From the Project menu, click References and add references to the following:

    • Microsoft CE ADO Control 3.1
    • Microsoft CE ADO ext. 3.1 for DDL
    • Microsoft CE SQL Server Control 1.0

REFERENCES

SQL Server CE Books Online topic "SQL Server CE Relay"

Modification Type:MinorLast Reviewed:7/12/2004
Keywords:kbhowto KB302349