Listing 1 Dim Rda As New SqlCeRemoteDataAccess Try ' Provide the info needed for the RDA class to know where to get the data. ' Where to find the local database. Rda.LocalConnectionString = "DataSource= \ProgramFiles\SSCEExample\SSCEExample.sdf" ' Where to find the server agent via HTTP requests. Rda.InternetUrl = "http://MyWebServerName/SSCEExample Synch/sscesa20.dll" ' When using Basic/Integrated, where you provide login information. Rda.InternetLogin = "" Rda.InternetPassword = "" Listing 2 ' If the database "file" is not there, let's create one. If File.Exists("\Program Files\SSCEExample\SSCEExample.sdf") Then File.Delete("\ProgramFiles\SSCEExample\SSCEExample.sdf") End If ' Create the local database, since RDA will not. ' Dim SSCEEng As New SqlCeEngine(Rda.LocalConnectionString) SSCEEng.CreateDatabase() Listing 3 ' We create Invoices and InvoiceDetails on the device, so we just need to turn on tracking by creating a query that returns nothing. HenceWHERE InvoiceID = '00000000-0000-0000-0000-000000000000' Rda.Pull("Invoice", "SELECT InvoiceID, CustomerID, InvoiceDate, SalesAgentID FROM Invoice WHERE InvoiceID = '00000000-0000-0000-0000-000000000000'", remoteConnString, RdaTrackOption.TrackingOnWithIndexes, "InvoiceErrors") Rda.Pull("InvoiceDetail", "SELECT InvoiceDetailID, InvoiceID, Qty, Amount FROM InvoiceDetail WHERE InvoiceDetailID = '00000000-0000-0000-0000-000000000000'", remoteConnString, RdaTrackOption.TrackingOnWithIndexes, "InvoiceDetailErrors") Listing 4 Dim repl As New SqlCeReplication ' If the database "file" is not there, let's create one. If File.Exists("\ProgramFiles\SSCEExample\SSCEExample.sdf") Then File.Delete("\ProgramFiles\SSCEExample\SSCEExample.sdf") End If ' Set Internet properties. ' InternetUrl is the endpoint for the HTTP calls, we set this up using the wizard. repl.InternetUrl = "http://cmayoevon800c2/SSCEExample Synch/ssc esa20.dll" repl.InternetLogin = "" repl.InternetPassword = "" ' Set Publisher properties. repl.Publisher = "MyMachineName" repl.PublisherDatabase = "SSCEExample" repl.Publication = "SSCEExamplePub" ' Set Publisher security properties. repl.PublisherSecurityMode = SecurityType.DBAuthentication repl.PublisherLogin = "sa" repl.PublisherPassword = "password" ' Set Subscriber properties. repl.SubscriberConnectionString = "DataSource= \ProgramFiles\SSCEExample\SSCEExample.sdf" repl.Subscriber = "MyUniqueSubName" Listing 5 '\This is used in the filter's Where clause in the Filter Rows tab of the publication. repl.HostName = 2 repl.ExchangeType = ExchangeType.BiDirectional Try ' Create the local database subscription.' repl.AddSubscription(AddOption. CreateDatabase) ' Synchronize to the SQL Server 2000 database to populate the local subscription database.' repl.Synchronize() ' Massively intelligent insert/update/delete code goes here so we can see the changes pushed back. ' Close the connection prior to push (only a single connection at a time). ' Synchronize to the SQL Server 2000 database to populate the local subscription database.' repl.Synchronize() Finally ' Dispose of the Replication object.' repl.Dispose() End Try