How to: Download a Snapshot of Data to a Client
This topic shows you how to download a snapshot of data from a server database to a SQL Server Compact client database. The examples in this topic focus on the following Sync Framework types:
For information about how to run sample code, see "Example Applications in the How to Topics" in Programming Common Client and Server Synchronization Tasks.
Example
The example code in this topic shows how to configure snapshot synchronization for the Customer, OrderHeader, and OrderDetail tables from the Sync Framework sample database. For an overview of the properties that are used to specify synchronization direction, see How to: Specify Snapshot, Download, Upload, and Bidirectional Synchronization.
Key Parts of the API
This section provides code examples that point out the key parts of the API that are used in snapshot synchronization. The following code example specifies synchronization direction and how the table should be created on the client.
The following code example specifies a command to select rows from the server to apply to the client. This is a SELECT statement that includes the columns to be synchronized. You can also add a WHERE clause to filter rows. For more information about filtering, see How to: Filter Rows and Columns. Because data is completely refreshed during each synchronization, the command does not include the tracking columns that are required for download-only and bidirectional synchronization.
Complete Code Example
The following complete code example includes the code examples that are described earlier and additional code to perform synchronization. Also be aware of how SyncStatistics is used to display information about the synchronization session. The example requires the Utility class that is available in Utility Class for Database Provider How-to Topics.
请参阅
其他资源
Architecture and Classes for Client and Server Synchronization
How to: Specify Snapshot, Download, Upload, and Bidirectional Synchronization