Home > Samples > Update > February 2003
          Back to associated article: .NET Compact Framework Emerges
  SQL CE and Data Access (Illustration)    
   

0203ncfe_illo1.gif (18371 bytes)

The .NET Compact Framework provides four ways to access a database from a compact device, as shown in the illustration above.

The top left box illustrates the simplest means: using ActiveSync to transfer a file containing XML data (which can be read and written with ADO.NET) from the device to a desktop PC. However, this simple model has significant limitations: it does not provide any method of reconciling changes should the device and the desktop application modify the same data, and it is only able to transfer data to a single PC.

Direct Database Access, shown in the top right box, allows the device to connect directly to a running instance of SQL Server using a two-tier, client/server architecture. The device application uses ADO.NET and the SQL CE provider to connect to SQL Server and retrieve or update data. This is easy for developers to implement and follows a design that is very familiar to developers. However, because each device connects directly to the SQL Server, it is not appropriate for applications where there may be large numbers of client devices and is more suitable for factory or shop floor scenarios.

Device applications can also retrieve data via Web services, shown in the middle box. Because the .NET Compact Framework supports Web services, device applications can use industry-standard protocols, such as the Simple Object Access Protocol (SOAP), to request data from a Web server (running ASP.NET in this case), which then uses ADO.NET to connect to the ultimate database source and return the requested data. Web services, however, are still evolving, and few organizations have deployed Web service front ends to their database systems.

Finally, the bottom picture shows a smart device running SQL Server CE in addition to the Compact Framework and using SQL Replication to transfer data between the device and an instance of SQL Server running on the network. Although running SQL CE on the device requires additional storage on the device, it provides several advantages, including support for querying local data, encrypted local storage, and a well-defined architecture for resolving conflicts that arise when multiple clients update the same record.