The What, Why, and How... Nino Benvenuti MVP – Device Application Development
Device Application Development
Why Local store Data store unification Store options What SQL CE Introduction Architecture How Deployment technologies Replication technologies Tools
Local store Server store Connectivity-aware Change reconciliation Connected Single data-source Database-driven Occasionally Connected Multiple data sources Data driven
Local Store Desktop apps have a local store? Store unification Benefits ▪ Architectural ▪ Data sharing ▪ Co$t Challenges ▪ Architectural ▪ Functional
Text file (.txt,.csv,.ini,.xml) Registry (What?!?!) Access FoxPro (R.I.P.) SQL Express Open-source DB Oracle, Sybase
SSQL CE SSQL Everywhere SSQL Mobile MMicrosoft SQL Server 2005 Compact Edition 33.1 SSQL CE SSQLce SSSCE
Server (1000’s of users) Workgroup (Dozens of users) Desktop (Single User) Laptop Tablet PC Windows CE Device Pocket PC Smart Phone Win 32 SQL Mobile SQL Express SQL Server SQL Server Compact Multi User Single User Scenarios Graphic courtesy Microsoft
Fully relational in-process database Win32 + Windows CE Secure OOB Sync Tools support both Developer and DBA Visual Studio ▪ Designer Experience, drag ‘n drop ▪ Server Explorer, Data Sources SQL Server Management Studio ▪ DB design/creation ▪ Interactive query
1.4 MB runtime Admin and Non-Admin deployment options Single-file, code-free format (.sdf) In-Proc with the hosting app DOES NOT run as a service Up to 4 gigabytes per database Multi connections for background data operations Simplified security w/password and encryption Transaction (yes, ACID) for batch operations Runs on mainline windows platforms (Windows Mobile/XP/2003) Common programming model through ADO.NET Auto re-use of empty pages Multiple sync options Proven, lightweight, 2-tier, scalable sync API (RDA) Full-featured merge replication Future investments for building occasionally-connected apps
CLR (.NET /.NET CF) Client Agent: Replication And RDA OLEDB / Replication API IIS CLIENT SERVER Storage Engine / Replication Tracking Server Agent: Replication and RDA HTTP b/a/g, CDPD, GSM, GPRS, CDMA, TDMA, etc. Data Provider SQL Server CE Data Provider SQL Server Client Data Provider ADO.NET Visual Studio 2005 (Visual Basic 2005 & C#) Managed Stack TDS Ethernet Well Connected Occasionally Connected OLEDB Visual Studio 2005 (C++) Native Stack OLEDB Provider QP/Cursor Engine SQL Server CE OLEDB SQL Server 2000 SQL Server 2005 Graphic courtesy Microsoft
SELECT IMEI, ProductCode, Quantity FROM (SELECT NULL AS IMEI, product AS ProductCode, (physicalqty - allocatedqty) AS Quantity FROM importstock WHERE (NOT mpstype IN(N'U', N'C', N'M', N'X', N'Y', N'P')) AND product IN (SELECT ProductCode FROM (SELECT importstock.product AS ProductCode FROM StockCountSchedule INNER JOIN StockCountProductCategories ON (StockCountSchedule.ID = StockCountProductCategories.ID) INNER JOIN importstock ON (StockCountProductCategories.Product_Type = importstock.product_type) WHERE (StockCountSchedule.IsRecount = 0) AND (StockCountSchedule.ID = ) UNION SELECT ProductCode FROM StockCountSchedule INNER JOIN CrossDevice_ProductsToRecount ON (StockCountSchedule.ID = CrossDevice_ProductsToRecount.StockCountID) WHERE (StockCountSchedule.IsRecount = 1) AND (StockCountSchedule.ID = )) AS StockCountProducts) UNION SELECT IMEI.imei AS IMEI, NULL AS ProductCode, NULL AS Quantity FROM importstock INNER JOIN IMEI ON importstock.product = IMEI.product WHERE (mpstype IN(N'U', N'C', N'M', N'X', N'Y', N'P')) AND importstock.product IN (SELECT ProductCode FROM (SELECT StockCountSchedule.ID AS StockCountID, importstock. product AS ProductCode FROM StockCountSchedule INNER JOIN StockCountProductCategories ON (StockCountSchedule.ID = StockCountProductCategories.ID) INNER JOIN importstock ON (StockCountProductCategories.Product_Type = importstock.product_type) WHERE (StockCountSchedule.IsRecount = 0) UNION SELECT StockCountSchedule.ID AS StockCountID, ProductCode FROM StockCountSchedule INNER JOIN CrossDevice_ProductsToRecount ON (StockCountSchedule.ID = CrossDevice_ProductsToRecount.StockCountID) WHERE (StockCountSchedule.IsRecount = 1)) AS StockCountProducts)) AS StockCountItems
Merge Replication True bidirectional data reconciliation Fullest-featured synchronization option Remote Data Access Unidirectional change tracking (device) Lightweight option Can be complimentary (like chocolate & peanut butter)
Client/server configuration Leveraged by both RDA & MR Client -> ActiveX ▪ SSCE via OLEDB ▪ Communication via HTTP(S) Server -> IIS / ISAPI extension ▪ Handles interaction with SQL Server
HTTP (S) OLE DB IIS SQL CE Server Agent SQL Server SQL CE Client Agent SQL CE Database SSCE Engine OLE DB Application SQL Server Provider
Server Mobile-aware data ▪ Specific ▪ Easily partitioned (time/date, geo) Filter column indexes Segregate data ▪ R-O vs R-W
Device-only change tracking Pull data from server ▪ No calculated columns Push changes Not much change from 3.0 Can now push/pull while db is in use Identity columns still problematic ▪ ALTER TABLE / manage range
True synchronization SSCE is the sub ▪ Gets initial snapshot from Server SQL Server is the pub Data changes on both ends reconciled during synchronization ▪ Server-managed, customizable conflict resolution
SQL Server 2005 now ‘mobile-aware’ ▪ Download-only tables ▪ Progress notification ▪ Partitioned groups
Multi-user access Multiple subscriptions / same db Background sync support Sends only changed columns Synchronization cancellation support Progress updates
SSMS Create pub / Define subs VS Define sub Initialize sub / Init sync
Sync Framework “Microsoft Sync Framework (MSF) is a comprehensive synchronization platform enabling collaboration and offline for applications, services and devices. Developers can build sync ecosystems that integrate any application, any data from any store using any protocol over any network. MSF features technologies and tools that enable roaming, sharing, and taking data offline.“
Since SQLce will run on the ‘desktop’, can I use it to back-end my ASP.NET website ? No. (but..) AppDomain.CurrentDomain.SetData(“SQLServerEver ywhereUnderWebHosting”,true)
Ships with Orcas (VS2008 /.NET (CF) 3.5) Can work w/.NET CF 2.0 & 3.5 90RTM publication compatible subscriber Will work (sync) with Yukon (2005) and Katmai (2008), but not Shiloh (2000) Support Synchronization Services for ADO.NET (desktop) LINQ support
VS2005 SP1 SQL Server 2005 SP2 SQL Server 2005 Compact Edition Tools for Visual Studio 2005 SQL Server 2005 Compact Edition Developer SDK SQL Server 2005 Compact Edition Books Online (May 2007) SQL Server 2005 Compact Edition Runtime SQL Server 2005 Compact Edition Server Tools
nologies/sqlcompact.mspx nologies/sqlcompact.mspx