| By Rowland Gosling | Article Rating: |
|
| May 10, 2005 12:00 PM EDT | Reads: |
19,505 |
Last fall I predicted that the next killer application would be built on the mobile platform, and so I bought a new PDA with a:
- 624MHz chip
- VGA
- Two kinds of expansion slots (CF I/II and SD)
- 192 MB of total memory (128 MB ROM, 64 MB SDRAM)
The night I bought the IPAQ I set it up on the kitchen table and got out my laptop. I wrote and deployed a simple list application in about two hours sans data. Of course that little program wasn't typical of any application. I only wanted to know how hard it would be to create and deploy an applicationThe answer was seductively easy.
That brings me to SQL Server 2005 Mobile Edition. Microsoft's latest data offering for the mobile market is a nice update from its SQL Server 2000 Windows CE Edition product. Noteworthy points include:
- An embedded version is underway that will let the engine be stored in ROM.
- Synchronization via HTTP
- Management through ActiveSync
- Interoperability with MicrosoftSQL Server 2000 (SP3A Required)
- Free redistribution for existing SQL Server 2000 and 2005 customers with registration
New Features
- A completely rewritten database engine
- Multiuser database support
- A new high-performance result set (SqlCeResultSet) that's part of the Compact Framework 2.0
Here's a short list of things that are missing in the SQL Mobile 2005 environment as far as you seasoned developers go:
- Triggers
- Stored Procedures
- Connection Pooling
- Distributed Transactions
- Encrypted Connection Strings
- Use of Integrated Security requires Connection Strings such as Integrated Security=SSPI, User ID=DOMAIN\username, Password=********
Design
Designing applications that run on small devices isn't a trival exercise. If you're going to build and deploy .NET applications using SQL Server 2005 Mobile Edition watch the details. Probably the single biggest decision is which replication strategy to use.- RDA Replication
- Merge Replication
- Custom Updating or None
Given a tiny form factor, good design is important. Unlike traditional desktop systems, you simply don't have a lot of room to work in. The performance of handhelds can be impressive, but it takes some doing. Start with something simple and work from there. By good design I mean the widget performs better than expected and all your lookup data is local. It might be a good idea to minimize the number of joins by denormalizing the data to boost performance.
Note: Only Unicode strings are supported on this platform and the smallmoney datatype isn't supported.
Supported Data Types
- bigint
- binary
- bit
- datetime
- float
- image
- integer
- money
- national character
- national character varying
- ntext
- numeric
- real
- smallint
- uniqueidentifier
- tinyint
- varbinary
Replication
For non-data-speaking folk, replication topics can be daunting because replication has its own jargon and word usage. Replication uses a publishing metaphor to refer to the individual parts and roles. It consists of publications and each publication consists of one or more articles. Servers can be set up to be both a publisher of data and a subscriber of other publications.Each publication is made up of one or more articles and there are two kinds of articles:
- Download-only articles (tables)
- Partitioned (filtered) articles
Folks who have pushed SQL replication around pretty hard over the years won't find the Transactional or Snapshot types that are available in the Enterprise product. Given the nature of what's being built I suppose that's okay. Snapshots would only be useful to populate lookup tables while Transactional would give us near real-time results,but at a near real-time price. You get something similar with RDA that works better on the small platform. If you come from a big SQL background, just think Merge Replication scenarios that can handle just about anything.
Merge Replication
You won't want for data, but you might beg for performance. We're in the major leagues of true replication here. Bidirectional (changes from either the server or client are posted on the other) means everyone with a subscription gets pretty much the same data barring the normal delays of replication. But is bidirectional required or desirable? Maybe. There's a performance hit at both ends. So? If you have the horsepower, it makes sense not to do the low-level plumbing code you need with RDA. With hardware so cheap these days it's pretty hard to make a big deal out of the slight difference.The heart of your design decision rests with the kind of application you're building. If you want a tightly coupled application where data is updated from both the PDA and the server, Merge Replication is your friend. I think of it as a "duplicate data everywhere" strategy. It would make sense to say, add new customers to a CRM application . But even that scenario has flaws starting with the obvious: would you really add a new customer in a form on your PDA? If you did, you'd probably need a BlueTooth keyboard.
I think Web Services is the way to go when possible and might be your best answer. Using Web Services over Merge Replication will work unless there's a compelling reason to use Merge Replication.-There's less to keep up with, it's easier to implement, and there's no mess to clean up if the publication stops working.
The main class in coding for Merge Replication is System.Data.SqlServerCe.SqlCeReplication.
RDA
Remote Data Access (RDA) is great for the semi-disconnected state because the model calls for downloading static data and only uploading the changes. This is great if a SmartPhone won't have access to the network for a while. You'll need to do some kind of lookup (such as inventory) and record data in tables on the device. Once connected, pass that information back to the server.The main class in coding for RDA replication is System.Data.SqlServerCe.SqlCeRemoteDataAccess.
Installation
SQL Server 2005 Mobile Edition is available:- As part of the SQL Server 2005 product (Yukon)
- As part of the Visual Studio.NET 2005 (Whidbey)
- As a separate download
Creating a New Database
Creating a new database is rather awkward in SQL Server Management Studio (MS SQL Server 2005's replacement for our old buddy Enterprise Manager) so I'm going to provide a little guidance here. First right click the server name to get the context menu, then click Connect, as shown in Figure 1.From the screen in Figure 2 you have to do two things: 1.) change the server type to SQL Mobile and 2.) pull down the New Database choice. Then just follow the prompts.
Enterprise Manager got a makeover and it is now called SQL Server Management Studio.
SqlCeResultSet - The New Scrollable Cursor
The Compact Framework 2.0 (available in Visual Studio 2005/Whidbey) comes with a new tool called SqlCeResultSet. Similar to the ADO.NET DataSet and DataReader, this result set provides better performance over the DataSet without the limitations of the DataReader (forward/read only). It's scrollable, updatable, and results from executing the SqlCeCommand object. Listing 1 shows a short example.Connection pooling isn't supported on this platform. You might want to leave the connections open instead of closing them when finished at least for the lifetime of the application.
Summary
Microsoft SQL Server 2005 Mobile Edition is an easy-to-use solution providing advanced data support to a wide range of mobile devices. Tight integration to other tools, such as Microsoft Visual Studio.NET 2005 and SQL Server Management Studio, provides a consistent toolset for working on mobile platforms.Resources
Downloads
Published May 10, 2005 Reads 19,505
Copyright © 2005 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Rowland Gosling
Rowland Gosling is a senior consultant for Magenic Technologies, Inc (www.magenic.com) a premier software development and consulting company focused on Microsoft technology. He specializes in data-centric applications using .NET and has also coauthored Professional Design Pattern in C# (Wrox Press, August 2003).
- Kindle 2 vs Nook
- Practical Approaches for Optimizing Website Performance
- SQL Anywhere Server and AJAX
- PowerBuilder Top Feature Picks
- The Difference Between Web Hosting and Cloud Computing
- PowerBuilder 12 and .NET
- Contrary Opinion: Why Silverlight is Good for Adobe
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Wave on Ulitzer: Confessions of a Google Wave Fanboy
- Cloud Computing Best Practices
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Rich Content Rotator for ASP.NET
- RIAs for Web 3.0 Using the Microsoft Platform
- Kindle 2 vs Nook
- Practical Approaches for Optimizing Website Performance
- Social Media Terrorists
- SQL Anywhere Server and AJAX
- SYS-CON's Cloud Expo Adds Two New Tracks
- PowerBuilder Top Feature Picks
- The Difference Between Web Hosting and Cloud Computing
- Google Maps and ASP.NET
- Crystal Reports XI & How It Has Changed
- Converting VB6 to VB.NET, Part I
- Creating Controls for.NET Compact Framework in Visual Studio 2005
- Where Are RIA Technologies Headed in 2008?
- How to Write High-Performance C# Code
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Implementing Tab Navigation with ASP.NET 2.0
- i-Technology Photo Exclusive: Bill Gates & Steve Jobs In "Nerds"
- .NET Archives: Getting Reacquainted with the Father of C#


































