[VSD] A newbie's guide to SqlMobile and device data development

I've been a really bad boy when it comes to blogging - not only have I been lazy with my updates, I've also neglected to post anything work related. So, I finally took out the time today to write out something close to my heart nowadays - working with data on devices. Hopefully, this is the first of many such posts. Before we dive in, let's answer a few questions that some of you new to device data development might have.

I can work with data on devices?

Duh! In VS 2005, you have the whole data experience that you have on the desktop and you even have certain things that the desktop guys dont :-). By 'data experience', I mean that you get all the wizards, the designers and all the other graphical goodness that the VBData team provides for the desktop

Am I stuck to just using databases?

Nope. When I say 'data', I mean any piece of information that your program works with.In fact, all of the UI we provide in VS will work just as well if you're using a bunch of .Net objects or a webservice as your data rather than any database.

So I use Sql Server?

Well, you could write code that directly makes queries against a remote Sql Server box. However, all the cool kids use SqlMobile and you really have no excuse not to.

Umm..what is Sql Mobile?

Sql Mobile is a super-lightweight, in-proc database that runs on devices.1.The key phrase for me personally is 'in-proc'. This means that there is no IPC involved and as a result, performance is blindingly fast. You can find out more on the official SqlMobile page.

A database on a device? You're kidding me

Nope. Cross my heart and hope to die and all that jazz. :-)

But why do I need a database on a device?

Well, for the same reasons you need a database on the desktop :-). Seriously though, SqlMobile is most frequently used as a 'local data store' where a subset of the data on SqlServer is pulled down to the device. You have 2 mechanisms to make SqlMobile stay in sync with SqlServer - merge replication and RDA2.

Let's say you're a big cola company and you want to keep track of all your trucks. You would use code against SqlMobile and let the truck drivers sync data before and after their shifts. That way, though they don't have any connectivity, they still have access to all the data they need. However, that's just scratching the surface of what you can do with SqlMobile.

So how do I program against SqlMobile?

Using Ado.Net of course! SqlMobile has its own provider and lets you use DataSets, DataReaders and all the other usual suspects in the Ado.Net family. And apart from this, it supports something spectacularly cool called ResultSets. I'll blog about that next.

Can I see more?

Yup! Stay tuned...